[Python-checkins] r78462 - in python/branches/py3k: Lib/test/test_codecs.py

florent.xicluna python-checkins at python.org
Fri Feb 26 12:12:34 CET 2010


Author: florent.xicluna
Date: Fri Feb 26 12:12:33 2010
New Revision: 78462

Log:
Merged revisions 78461 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78461 | florent.xicluna | 2010-02-26 11:40:58 +0100 (ven, 26 fév 2010) | 2 lines
  
  #691291: codecs.open() should not convert end of lines on reading and writing.
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Lib/test/test_codecs.py

Modified: python/branches/py3k/Lib/test/test_codecs.py
==============================================================================
--- python/branches/py3k/Lib/test/test_codecs.py	(original)
+++ python/branches/py3k/Lib/test/test_codecs.py	Fri Feb 26 12:12:33 2010
@@ -483,6 +483,21 @@
         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"
 


More information about the Python-checkins mailing list