1. Armin Rigo
  2. cpython-withatomic


Benjamin Peterson  committed 720804a

raise an ValueError in getvalue() on closed StringIO (closes #12161)

Thanks for Catalin Iacob for the patch.

  • Participants
  • Parent commits 7724b53
  • Branches 2.7

Comments (0)

Files changed (4)

File Lib/StringIO.py

View file
         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 = []

File Lib/test/test_StringIO.py

View file
         self.assertRaises(ValueError, self._fp.next)
+    def test_getvalue(self):
+        self._fp.close()
+        self.assertRaises(ValueError, self._fp.getvalue)
 class TestStringIO(TestGenericStringIO):
     MODULE = StringIO

File Misc/ACKS

View file
 Jeremy Hylton
 Gerhard Häring
 Fredrik Håård
+Catalin Iacob
 Mihai Ibanescu
 Lars Immisch
 Bobby Impollonia

File Misc/NEWS

View file
+- Issue #12161: Cause StringIO.getvalue() to raise a ValueError when used on a
+  closed StringIO instance.
 - Issue #12182: Fix pydoc.HTMLDoc.multicolumn() if Python uses the new (true)
   division (python -Qnew). Patch written by Ralf W. Grosse-Kunstleve.