[Python-checkins] r55619 - in python/branches/cpy_merge/Lib: StringIO.py test/test_StringIO.py
alexandre.vassalotti
python-checkins at python.org
Mon May 28 17:14:28 CEST 2007
Author: alexandre.vassalotti
Date: Mon May 28 17:14:23 2007
New Revision: 55619
Modified:
python/branches/cpy_merge/Lib/StringIO.py
python/branches/cpy_merge/Lib/test/test_StringIO.py
Log:
Raise a ValueError when .getvalue() is invoked after .close()
Added a test to check this new behavior.
Modified: python/branches/cpy_merge/Lib/StringIO.py
==============================================================================
--- python/branches/cpy_merge/Lib/StringIO.py (original)
+++ python/branches/cpy_merge/Lib/StringIO.py Mon May 28 17:14:23 2007
@@ -267,6 +267,7 @@
8th bit) will cause a UnicodeError to be raised when getvalue()
is called.
"""
+ _complain_ifclosed(self.closed)
if self.buflist:
self.buf += ''.join(self.buflist)
self.buflist = []
Modified: python/branches/cpy_merge/Lib/test/test_StringIO.py
==============================================================================
--- python/branches/cpy_merge/Lib/test/test_StringIO.py (original)
+++ python/branches/cpy_merge/Lib/test/test_StringIO.py Mon May 28 17:14:23 2007
@@ -98,6 +98,11 @@
self._fp.close()
self.assertRaises(ValueError, next, self._fp)
+ def test_getvalue(self):
+ f = self.MODULE.StringIO()
+ f.close()
+ self.assertRaises(ValueError, f.getvalue)
+
class TestStringIO(TestGenericStringIO):
MODULE = StringIO
More information about the Python-checkins
mailing list