[Python-checkins] r76801 - in python/branches/release26-maint: Lib/StringIO.py Lib/test/test_StringIO.py Misc/NEWS

benjamin.peterson python-checkins at python.org
Sun Dec 13 18:34:05 CET 2009


Author: benjamin.peterson
Date: Sun Dec 13 18:34:05 2009
New Revision: 76801

Log:
Merged revisions 76798-76799 via svnmerge from 
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
........


Modified:
   python/branches/release26-maint/   (props changed)
   python/branches/release26-maint/Lib/StringIO.py
   python/branches/release26-maint/Lib/test/test_StringIO.py
   python/branches/release26-maint/Misc/NEWS

Modified: python/branches/release26-maint/Lib/StringIO.py
==============================================================================
--- python/branches/release26-maint/Lib/StringIO.py	(original)
+++ python/branches/release26-maint/Lib/StringIO.py	Sun Dec 13 18:34:05 2009
@@ -158,7 +158,7 @@
             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]

Modified: python/branches/release26-maint/Lib/test/test_StringIO.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_StringIO.py	(original)
+++ python/branches/release26-maint/Lib/test/test_StringIO.py	Sun Dec 13 18:34:05 2009
@@ -28,6 +28,8 @@
         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()

Modified: python/branches/release26-maint/Misc/NEWS
==============================================================================
--- python/branches/release26-maint/Misc/NEWS	(original)
+++ python/branches/release26-maint/Misc/NEWS	Sun Dec 13 18:34:05 2009
@@ -35,6 +35,9 @@
 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.
 


More information about the Python-checkins mailing list