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:
parent
4a53dadc3e
commit
0af5d93d8a
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue