From fd66919ecc7570ff1f3edd95f0dc5be8d8a8b888 Mon Sep 17 00:00:00 2001 From: kernc Date: Tue, 6 Jan 2015 02:39:13 +0100 Subject: Encode the output to UTF-8 before writing to file 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. --- scss/tool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scss/tool.py b/scss/tool.py index 08abb44..a348e9c 100644 --- a/scss/tool.py +++ b/scss/tool.py @@ -250,8 +250,8 @@ def watch_sources(options): 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) -- cgit v1.2.1