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.
This commit is contained in:
Walter Dörwald 2006-03-15 08:23:53 +00:00
parent 4a53dadc3e
commit 0af5d93d8a
2 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -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