diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-13 10:26:58 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-13 10:26:58 (GMT) |
commit | 8d7d6bcc2519066ba04f3c63d6ae8d2897a94282 (patch) | |
tree | 03622015920e98f626e439d72941ecdb6480b4b8 | |
parent | 34fe1b7a3db61ee1b92f495488b08532b6126450 (diff) | |
download | cpython-8d7d6bcc2519066ba04f3c63d6ae8d2897a94282.zip cpython-8d7d6bcc2519066ba04f3c63d6ae8d2897a94282.tar.gz cpython-8d7d6bcc2519066ba04f3c63d6ae8d2897a94282.tar.bz2 |
Issue #11311: StringIO.readline(0) now returns an empty string as all other
file-like objects.
-rw-r--r-- | Lib/StringIO.py | 2 | ||||
-rw-r--r-- | Lib/test/test_StringIO.py | 2 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
3 files changed, 6 insertions, 1 deletions
diff --git a/Lib/StringIO.py b/Lib/StringIO.py index f74a066..b63525b 100644 --- a/Lib/StringIO.py +++ b/Lib/StringIO.py @@ -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] diff --git a/Lib/test/test_StringIO.py b/Lib/test/test_StringIO.py index 84b2b08..37a825f 100644 --- a/Lib/test/test_StringIO.py +++ b/Lib/test/test_StringIO.py @@ -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. |