bpo-11594: Ensure line-endings are respected when using 2to3 (GH-6483)
(cherry picked from commit c127a86e1862df88ec6f9d15b79c627fc616766e)
Co-authored-by: Aaron Ang <aaronang@users.noreply.github.com>
diff --git a/Lib/lib2to3/refactor.py b/Lib/lib2to3/refactor.py
index db2e38d..7c4e064 100644
--- a/Lib/lib2to3/refactor.py
+++ b/Lib/lib2to3/refactor.py
@@ -314,7 +314,7 @@
encoding = tokenize.detect_encoding(f.readline)[0]
finally:
f.close()
- with io.open(filename, "r", encoding=encoding) as f:
+ with io.open(filename, "r", encoding=encoding, newline='') as f:
return f.read(), encoding
def refactor_file(self, filename, write=False, doctests_only=False):