Skip to content

Commit

Permalink
Encode the output to UTF-8 before writing to file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kernc committed Jan 6, 2015
1 parent f26e994 commit fd66919
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scss/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ def compile(self, src_path):
dest_path = os.path.join(os.path.dirname(src_path), fname)

print("Compiling %s => %s" % (src_path, dest_path))
dest_file = open(dest_path, 'w')
dest_file.write(self.css.compile(scss_file=src_path))
dest_file = open(dest_path, 'wb')
dest_file.write(self.css.compile(scss_file=src_path).encode('utf-8'))

def on_moved(self, event):
super(ScssEventHandler, self).on_moved(event)
Expand Down

0 comments on commit fd66919

Please sign in to comment.