summaryrefslogtreecommitdiff
path: root/scss/tool.py
diff options
context:
space:
mode:
authorkernc <kerncece@gmail.com>2015-01-06 02:39:13 +0100
committerKernc <kerncece@gmail.com>2015-01-06 14:21:50 +0100
commitfd66919ecc7570ff1f3edd95f0dc5be8d8a8b888 (patch)
treea04dabe60fb84b3cea02ce00acde61ed76db61d4 /scss/tool.py
parentf26e99445dc8eada34406fab7185480f252bdb6c (diff)
downloadpyscss-fd66919ecc7570ff1f3edd95f0dc5be8d8a8b888.tar.gz
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.
Diffstat (limited to 'scss/tool.py')
-rw-r--r--scss/tool.py4
1 files 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)