Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e36b2c6

Browse files
committed
Recorded merge of revisions 78462,78484 via svnmerge from
svn+ssh://[email protected]/python/branches/py3k ................ r78462 | florent.xicluna | 2010-02-26 12:12:33 +0100 (ven, 26 fév 2010) | 9 lines Merged revisions 78461 via svnmerge from svn+ssh://[email protected]/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. ........ ................ r78484 | florent.xicluna | 2010-02-27 12:31:21 +0100 (sam, 27 fév 2010) | 9 lines Merged revisions 78482 via svnmerge from svn+ssh://[email protected]/python/trunk ........ r78482 | florent.xicluna | 2010-02-27 12:19:18 +0100 (sam, 27 fév 2010) | 2 lines Add entry for issue #691291. ........ ................
1 parent 8a0212e commit e36b2c6

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

Lib/test/test_codecs.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,21 @@ def test_decoder_state(self):
483483
self.check_state_handling_decode(self.encoding,
484484
"spamspam", self.spambe)
485485

486+
def test_bug691291(self):
487+
# Files are always opened in binary mode, even if no binary mode was
488+
# specified. This means that no automatic conversion of '\n' is done
489+
# on reading and writing.
490+
s1 = 'Hello\r\nworld\r\n'
491+
492+
s = s1.encode(self.encoding)
493+
try:
494+
with open(support.TESTFN, 'wb') as fp:
495+
fp.write(s)
496+
with codecs.open(support.TESTFN, 'U', encoding=self.encoding) as reader:
497+
self.assertEqual(reader.read(), s1)
498+
finally:
499+
support.unlink(support.TESTFN)
500+
486501
class UTF16LETest(ReadTest):
487502
encoding = "utf-16-le"
488503

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ Core and Builtins
9292
Library
9393
-------
9494

95+
- Issue #691291: codecs.open() should not convert end of lines on reading and
96+
writing.
97+
9598
- Issue #7959: ctypes callback functions are now registered correctly
9699
with the cycle garbage collector.
97100

0 commit comments

Comments
 (0)