From c0b59934ec9d33af3aee6cf4f3a6b4b132897857 Mon Sep 17 00:00:00 2001 From: John Chadwick Date: Sun, 11 Feb 2018 02:21:05 -0500 Subject: [PATCH] Do not apply line endings twice. (#671) At least on some occasions, setting `newline` to whatever the line endings currently are can cause Python to replace the `\n`s with whatever you pass in, causing lines to be encoded twice. This leads to CRLF files containing `\r\r\n` sequences in place of `\r\n`. --- isort/isort.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/isort/isort.py b/isort/isort.py index 1d981edac..3ba3e7d19 100644 --- a/isort/isort.py +++ b/isort/isort.py @@ -211,7 +211,7 @@ def __init__(self, file_path=None, file_contents=None, write_to_stdout=False, ch return if answer in ('quit', 'q'): sys.exit(1) - with io.open(self.file_path, encoding=self.file_encoding, mode='w', newline=self.line_separator) as output_file: + with io.open(self.file_path, encoding=self.file_encoding, mode='w', newline='') as output_file: print("Fixing {0}".format(self.file_path)) output_file.write(self.output)