diff options
author | Walter Dörwald <walter@livinglogic.de> | 2005-04-21 21:53:43 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2005-04-21 21:53:43 (GMT) |
commit | 4d3fec604dadbffe5211c6ca21fa05c72cbceefd (patch) | |
tree | 6e8f2d9451889a0884ac2b6aabfcbd1c549ebce7 /Lib/test/test_codecs.py | |
parent | 21287ee5bc46d54cf041f75f857c0fc0e5dde754 (diff) | |
download | cpython-4d3fec604dadbffe5211c6ca21fa05c72cbceefd.zip cpython-4d3fec604dadbffe5211c6ca21fa05c72cbceefd.tar.gz cpython-4d3fec604dadbffe5211c6ca21fa05c72cbceefd.tar.bz2 |
Backport checkin (and the appropriate fix to the test):
If the data read from the bytestream in readline() ends in a '\r' read one more
byte, even if the user has passed a size parameter. This extra byte shouldn't
cause a buffer overflow in the tokenizer. The original plan was to return a line
ending in '\r', which might be recognizable as a complete line and skip any '\n'
that was read afterwards. Unfortunately this didn't work, as the tokenizer only
recognizes '\n' as line ends, which in turn lead to joined lines and
SyntaxErrors, so this special treatment of a split '\r\n' has been dropped. (It
can only happen with a temporarily exhausted bytestream now anyway.)
Fixes parts of SF bugs #1163244 and #1175396.
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r-- | Lib/test/test_codecs.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index 7a19b32..93c5ff1 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -176,6 +176,7 @@ class ReadTest(unittest.TestCase): writer.write(u"foo\r") self.assertEqual(reader.readline(keepends=False), u"foo") writer.write(u"\nbar\r") + self.assertEqual(reader.readline(keepends=False), u"") self.assertEqual(reader.readline(keepends=False), u"bar") writer.write(u"baz") self.assertEqual(reader.readline(keepends=False), u"baz") @@ -185,6 +186,7 @@ class ReadTest(unittest.TestCase): writer.write(u"foo\r") self.assertEqual(reader.readline(keepends=True), u"foo\r") writer.write(u"\nbar\r") + self.assertEqual(reader.readline(keepends=True), u"\n") self.assertEqual(reader.readline(keepends=True), u"bar\r") writer.write(u"baz") self.assertEqual(reader.readline(keepends=True), u"baz") |