summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCluas <Cluas@live.cn>2019-04-15 00:25:51 +0800
committerCluas <Cluas@live.cn>2019-04-15 00:25:51 +0800
commitc8ef839417516032c45bc48d4d041aa04aafae0d (patch)
tree723755c1fc57a239693c83849a330c511a17e217
parent7f0363429a633df2c53cfbb9beae0360e27acd75 (diff)
downloadisort-c8ef839417516032c45bc48d4d041aa04aafae0d.tar.gz
fix: fix py2 in "isort -" std.write raise UnicodeEncodeError.
When there is a non-asaii code character in the file, an error will be reported in python2.
-rw-r--r--isort/isort.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/isort/isort.py b/isort/isort.py
index 7ae539d5..991aed51 100644
--- a/isort/isort.py
+++ b/isort/isort.py
@@ -236,6 +236,8 @@ class SortImports(object):
if show_diff or self.config['show_diff']:
self._show_diff(file_contents)
elif write_to_stdout:
+ if sys.version_info[0] < 3:
+ self.output = self.output.encode(self.file_encoding)
sys.stdout.write(self.output)
elif file_name and not check:
if self.output == file_contents: