Kaydet (Commit) 8d7d6bcc authored tarafından Serhiy Storchaka's avatar Serhiy Storchaka

Issue #11311: StringIO.readline(0) now returns an empty string as all other

file-like objects.
üst 34fe1b7a
......@@ -158,7 +158,7 @@ class StringIO:
newpos = self.len
else:
newpos = i+1
if length is not None and length > 0:
if length is not None and length >= 0:
if self.pos + length < newpos:
newpos = self.pos + length
r = self.buf[self.pos:newpos]
......
......@@ -28,6 +28,8 @@ class TestGenericStringIO(unittest.TestCase):
eq = self.assertEqual
self.assertRaises(TypeError, self._fp.seek)
eq(self._fp.read(10), self._line[:10])
eq(self._fp.read(0), '')
eq(self._fp.readline(0), '')
eq(self._fp.readline(), self._line[10:] + '\n')
eq(len(self._fp.readlines(60)), 2)
self._fp.seek(0)
......
......@@ -205,6 +205,9 @@ Core and Builtins
Library
-------
- Issue #11311: StringIO.readline(0) now returns an empty string as all other
file-like objects.
- Issue #16800: tempfile.gettempdir() no longer left temporary files when
the disk is full. Original patch by Amir Szekely.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment