Kronuz / pyScss

pyScss, a Scss compiler for Python
MIT License
582 stars 141 forks source link

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

Closed kernc closed 9 years ago

kernc commented 9 years ago

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 commented 9 years ago

Coverage Status

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

eevee commented 9 years ago

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

kernc commented 9 years ago

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

coveralls commented 9 years ago

Coverage Status

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

eevee commented 9 years ago

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.