mirror of
https://github.com/python/cpython.git
synced 2025-09-17 14:16:02 +00:00
raise an ValueError in getvalue() on closed StringIO (closes #12161)
Thanks for Catalin Iacob for the patch.
This commit is contained in:
parent
dbfba1667c
commit
4fa68ab10b
4 changed files with 9 additions and 0 deletions
|
@ -266,6 +266,7 @@ class StringIO:
|
||||||
8th bit) will cause a UnicodeError to be raised when getvalue()
|
8th bit) will cause a UnicodeError to be raised when getvalue()
|
||||||
is called.
|
is called.
|
||||||
"""
|
"""
|
||||||
|
_complain_ifclosed(self.closed)
|
||||||
if self.buflist:
|
if self.buflist:
|
||||||
self.buf += ''.join(self.buflist)
|
self.buf += ''.join(self.buflist)
|
||||||
self.buflist = []
|
self.buflist = []
|
||||||
|
|
|
@ -100,6 +100,10 @@ class TestGenericStringIO(unittest.TestCase):
|
||||||
self._fp.close()
|
self._fp.close()
|
||||||
self.assertRaises(ValueError, self._fp.next)
|
self.assertRaises(ValueError, self._fp.next)
|
||||||
|
|
||||||
|
def test_getvalue(self):
|
||||||
|
self._fp.close()
|
||||||
|
self.assertRaises(ValueError, self._fp.getvalue)
|
||||||
|
|
||||||
class TestStringIO(TestGenericStringIO):
|
class TestStringIO(TestGenericStringIO):
|
||||||
MODULE = StringIO
|
MODULE = StringIO
|
||||||
|
|
||||||
|
|
|
@ -382,6 +382,7 @@ Eric Huss
|
||||||
Jeremy Hylton
|
Jeremy Hylton
|
||||||
Gerhard Häring
|
Gerhard Häring
|
||||||
Fredrik Håård
|
Fredrik Håård
|
||||||
|
Catalin Iacob
|
||||||
Mihai Ibanescu
|
Mihai Ibanescu
|
||||||
Lars Immisch
|
Lars Immisch
|
||||||
Bobby Impollonia
|
Bobby Impollonia
|
||||||
|
|
|
@ -83,6 +83,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- 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)
|
- Issue #12182: Fix pydoc.HTMLDoc.multicolumn() if Python uses the new (true)
|
||||||
division (python -Qnew). Patch written by Ralf W. Grosse-Kunstleve.
|
division (python -Qnew). Patch written by Ralf W. Grosse-Kunstleve.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue