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