summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-02-26 11:12:33 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-02-26 11:12:33 (GMT)
commitc1c415f304e499b963131a83293bde07dcabc821 (patch)
tree04c751ce145324aad58ee929a077dd0411b3faa7 /Lib
parent7e557a6e1f998e1bb5a03fe2d3087f8a78f6e208 (diff)
downloadcpython-c1c415f304e499b963131a83293bde07dcabc821.zip
cpython-c1c415f304e499b963131a83293bde07dcabc821.tar.gz
cpython-c1c415f304e499b963131a83293bde07dcabc821.tar.bz2
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. ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_codecs.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 4b4d40c..974ebd4 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"