summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_codecs.py15
-rw-r--r--Misc/NEWS3
2 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index d0bcf56..2c646ba 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -483,6 +483,21 @@ class UTF16Test(ReadTest):
self.check_state_handling_decode(self.encoding,
"spamspam", self.spambe)
+ def test_bug691291(self):
+ # Files are always opened in binary mode, even if no binary mode was
+ # specified. This means that no automatic conversion of '\n' is done
+ # on reading and writing.
+ s1 = 'Hello\r\nworld\r\n'
+
+ s = s1.encode(self.encoding)
+ try:
+ with open(support.TESTFN, 'wb') as fp:
+ fp.write(s)
+ with codecs.open(support.TESTFN, 'U', encoding=self.encoding) as reader:
+ self.assertEqual(reader.read(), s1)
+ finally:
+ support.unlink(support.TESTFN)
+
class UTF16LETest(ReadTest):
encoding = "utf-16-le"
diff --git a/Misc/NEWS b/Misc/NEWS
index 64d5309..9e0bc6a 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -92,6 +92,9 @@ Core and Builtins
Library
-------
+- Issue #691291: codecs.open() should not convert end of lines on reading and
+ writing.
+
- Issue #7959: ctypes callback functions are now registered correctly
with the cycle garbage collector.