summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Edmund Crosley <timothy.crosley@gmail.com>2019-04-14 11:09:45 -0700
committerGitHub <noreply@github.com>2019-04-14 11:09:45 -0700
commit05c3592dd61af2bce67306097a057f8c7f0a69f2 (patch)
tree723755c1fc57a239693c83849a330c511a17e217
parent7f0363429a633df2c53cfbb9beae0360e27acd75 (diff)
parentc8ef839417516032c45bc48d4d041aa04aafae0d (diff)
downloadisort-05c3592dd61af2bce67306097a057f8c7f0a69f2.tar.gz
Merge pull request #925 from Cluas/fix-python2-stdout-write-unicode-error
Fix: "isort -" will raise UnicodeEncodeError on 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: