Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode the output to UTF-8 before writing to file #325

Merged
merged 1 commit into from
Jan 6, 2015

Conversation

kernc
Copy link
Contributor

@kernc kernc commented Jan 6, 2015

Having run pyScss with --watch, it died with:

  File "/usr/local/lib/python2.7/dist-packages/scss/tool.py", line 254, in compile
    dest_file.write(self.css.compile(scss_file=src_path))
UnicodeEncodeError: 'ascii' codec can't encode character u'\uf0d7' in position 816: ordinal not in range(128)

(My CSS includes content: ''; line.)

Encoding to UTF-8, assuming that's what everyone wants, before writing the file, solves it.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling e90108a on kernc:patch-1 into f26e994 on Kronuz:master.

@eevee
Copy link
Collaborator

eevee commented Jan 6, 2015

This will break on Python 3, where you can't write bytes to a file opened in text mode (the default).

Having run pyScss with `--watch`, it died with:
```
  File "/usr/local/lib/python2.7/dist-packages/scss/tool.py", line 254, in compile
    dest_file.write(self.css.compile(scss_file=src_path))
UnicodeEncodeError: 'ascii' codec can't encode character u'\uf0d7' in position 816: ordinal not in range(128)
```
Encoding to UTF-8, assuming that's what everyone wants, before writing the file, solves it.
@kernc
Copy link
Contributor Author

kernc commented Jan 6, 2015

Thanks for catching that. Would this now work? How would I go about writing a test for --watch flag?

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling fd66919 on kernc:patch-1 into f26e994 on Kronuz:master.

@eevee
Copy link
Collaborator

eevee commented Jan 6, 2015

That should do it :)

I suppose you'd have to either fake out a bunch of stuff (gross), or actually write a test that spawns a subprocess and writes out files and waits to see if the subprocess picks them up.

eevee added a commit that referenced this pull request Jan 6, 2015
Encode the output to UTF-8 before writing to file
@eevee eevee merged commit 9cf89dc into Kronuz:master Jan 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants