Index: Lib/test/test_codecs.py =================================================================== --- Lib/test/test_codecs.py (revision 76622) +++ Lib/test/test_codecs.py (working copy) @@ -3,6 +3,8 @@ import codecs import sys, _testcapi, io +from test.support import TESTFN, unlink + class Queue(object): """ queue: write bytes at one end, read bytes from the other end @@ -483,6 +485,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(TESTFN, 'wb') as fp: + fp.write(s) + with codecs.open(TESTFN, 'U', encoding=self.encoding) as reader: + self.assertEqual(reader.read(), s1) + finally: + unlink(TESTFN) + class UTF16LETest(ReadTest): encoding = "utf-16-le"

AltStyle によって変換されたページ (->オリジナル) /