From: Walter Dörwald Date: Wed, 15 Mar 2006 08:23:53 +0000 (+0000) Subject: SF patch #1359365: file and cStringIO raise a ValueError when next() is called X-Git-Tag: v2.5a0~245 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0af5d93d8a9ce44343630c24140977fa841dfe04;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Lib/StringIO.py b/Lib/StringIO.py index 5c463fbc1c94..1e5f25408d70 100644 --- a/Lib/StringIO.py +++ b/Lib/StringIO.py @@ -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 diff --git a/Lib/test/test_StringIO.py b/Lib/test/test_StringIO.py index c61f7cc54a3c..a2e544458b7f 100644 --- a/Lib/test/test_StringIO.py +++ b/Lib/test/test_StringIO.py @@ -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