[Python-checkins] python/dist/src/Lib/test test_codecs.py,,

doerwalter at users.sourceforge.net doerwalter at users.sourceforge.net
Thu Apr 21 23:53:45 CEST 2005

Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32723/Lib/test

Modified Files:
      Tag: release24-maint
Log Message:
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.

Index: test_codecs.py
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecs.py,v
retrieving revision
retrieving revision
diff -u -d -r1.15.2.4 -r1.15.2.5
--- test_codecs.py	4 Apr 2005 21:56:28 -0000
+++ test_codecs.py	21 Apr 2005 21:53:43 -0000
@@ -176,6 +176,7 @@
         self.assertEqual(reader.readline(keepends=False), u"foo")
+        self.assertEqual(reader.readline(keepends=False), u"")
         self.assertEqual(reader.readline(keepends=False), u"bar")
         self.assertEqual(reader.readline(keepends=False), u"baz")
@@ -185,6 +186,7 @@
         self.assertEqual(reader.readline(keepends=True), u"foo\r")
+        self.assertEqual(reader.readline(keepends=True), u"\n")
         self.assertEqual(reader.readline(keepends=True), u"bar\r")
         self.assertEqual(reader.readline(keepends=True), u"baz")

More information about the Python-checkins mailing list