Commit 0af5d93d authored by Walter Dörwald's avatar Walter Dörwald

SF patch #1359365: file and cStringIO raise a ValueError when next() is called

after calling close(). Change StringIO, so that it behaves the same way.
parent 4a53dadc
......@@ -72,8 +72,7 @@ class StringIO:
method is called repeatedly. This method returns the next input line,
or raises StopIteration when EOF is hit.
"""
if self.closed:
raise StopIteration
_complain_ifclosed(self.closed)
r = self.readline()
if not r:
raise StopIteration
......
......@@ -87,6 +87,8 @@ class TestGenericStringIO(unittest.TestCase):
eq(line, self._line + '\n')
i += 1
eq(i, 5)
self._fp.close()
self.assertRaises(ValueError, self._fp.next)
class TestStringIO(TestGenericStringIO):
MODULE = StringIO
......
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