summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2018-07-13 15:26:03 (GMT)
committerGitHub <noreply@github.com>2018-07-13 15:26:03 (GMT)
commitcafaf0447b950fd4f59edd8cbde040c61ae528f8 (patch)
tree16bc635ab64861d1714134a6dafa810fb2b9b45a
parent379e9d639a52766f79c7a206c5096c8333d1896f (diff)
downloadcpython-cafaf0447b950fd4f59edd8cbde040c61ae528f8.zip
cpython-cafaf0447b950fd4f59edd8cbde040c61ae528f8.tar.gz
cpython-cafaf0447b950fd4f59edd8cbde040c61ae528f8.tar.bz2
bpo-34108: Fix double carriage return in 2to3 on Windows (#8271)
* Add test capturing failure. * Honor newlines as present in the original file.
-rw-r--r--Lib/lib2to3/refactor.py2
-rw-r--r--Lib/lib2to3/tests/test_refactor.py1
-rw-r--r--Misc/NEWS.d/next/Library/2018-07-13-08-44-52.bpo-34108.RjobUC.rst1
3 files changed, 3 insertions, 1 deletions
diff --git a/Lib/lib2to3/refactor.py b/Lib/lib2to3/refactor.py
index 7c4e064..7841b99 100644
--- a/Lib/lib2to3/refactor.py
+++ b/Lib/lib2to3/refactor.py
@@ -514,7 +514,7 @@ class RefactoringTool(object):
set.
"""
try:
- fp = io.open(filename, "w", encoding=encoding)
+ fp = io.open(filename, "w", encoding=encoding, newline='')
except OSError as err:
self.log_error("Can't create %s: %s", filename, err)
return
diff --git a/Lib/lib2to3/tests/test_refactor.py b/Lib/lib2to3/tests/test_refactor.py
index f3059a9..9e3b8fb 100644
--- a/Lib/lib2to3/tests/test_refactor.py
+++ b/Lib/lib2to3/tests/test_refactor.py
@@ -300,6 +300,7 @@ from __future__ import print_function"""
old, new = self.refactor_file(fn)
self.assertIn(b"\r\n", old)
self.assertIn(b"\r\n", new)
+ self.assertNotIn(b"\r\r\n", new)
def test_refactor_docstring(self):
rt = self.rt()
diff --git a/Misc/NEWS.d/next/Library/2018-07-13-08-44-52.bpo-34108.RjobUC.rst b/Misc/NEWS.d/next/Library/2018-07-13-08-44-52.bpo-34108.RjobUC.rst
new file mode 100644
index 0000000..1021f98
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-07-13-08-44-52.bpo-34108.RjobUC.rst
@@ -0,0 +1 @@
+Remove extraneous CR in 2to3 refactor.