diff options
author | Cluas <Cluas@live.cn> | 2019-04-15 00:25:51 +0800 |
---|---|---|
committer | Cluas <Cluas@live.cn> | 2019-04-15 00:25:51 +0800 |
commit | c8ef839417516032c45bc48d4d041aa04aafae0d (patch) | |
tree | 723755c1fc57a239693c83849a330c511a17e217 | |
parent | 7f0363429a633df2c53cfbb9beae0360e27acd75 (diff) | |
download | isort-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.py | 2 |
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: |