]> granicus.if.org Git - python/commitdiff
Merged revisions 76798-76799 via svnmerge from
authorBenjamin Peterson <benjamin@python.org>
Sun, 13 Dec 2009 17:34:05 +0000 (17:34 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sun, 13 Dec 2009 17:34:05 +0000 (17:34 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r76798 | benjamin.peterson | 2009-12-13 11:29:16 -0600 (Sun, 13 Dec 2009) | 1 line

  make StringIO like other file objects in that readline(-1) has no effect #7348
........
  r76799 | benjamin.peterson | 2009-12-13 11:31:31 -0600 (Sun, 13 Dec 2009) | 1 line

  add NEWS note
........

Lib/StringIO.py
Lib/test/test_StringIO.py
Misc/NEWS

index 232009fb9397e27d9b1465c28ee5f24e583c5943..300dd5a2429b42a8390d4334720c89228ac84289 100644 (file)
@@ -158,7 +158,7 @@ class StringIO:
             newpos = self.len
         else:
             newpos = i+1
-        if length is not None:
+        if length is not None and length > 0:
             if self.pos + length < newpos:
                 newpos = self.pos + length
         r = self.buf[self.pos:newpos]
index 58cbec06f85901e010f53f0058930a93c208c049..81f81e58aefc1d7d4e8041f0aa73c71c18b710b6 100644 (file)
@@ -28,6 +28,8 @@ class TestGenericStringIO(unittest.TestCase):
         eq(self._fp.read(10), self._line[:10])
         eq(self._fp.readline(), self._line[10:] + '\n')
         eq(len(self._fp.readlines(60)), 2)
+        self._fp.seek(0)
+        eq(self._fp.readline(-1), self._line + '\n')
 
     def test_writes(self):
         f = self.MODULE.StringIO()
index d9cb038f819475c9af100650263636ad0e3bbda4..a933f62584911452a08de04829156ea0b843d989 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -35,6 +35,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #7348: StringIO.StringIO.readline(-1) now acts as if it got no argument
+  like other file objects.
+
 - Issue #5949: fixed IMAP4_SSL hang when the IMAP server response is
   missing proper end-of-line termination.