aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-02-03 09:30:51 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2015-02-03 09:30:51 +0200
commit32ca3dcb97a75c05dc2b90c88bbf82a541c57c61 (patch)
tree60e9b695fbc4017a34f2202beef337eb01c347db /Lib/_pyio.py
parentIssues #23363, #23364, #23365, #23366: Fixed itertools overflow tests. (diff)
parentIssue #23099: Closing io.BytesIO with exported buffer is rejected now to (diff)
downloadcpython-32ca3dcb97a75c05dc2b90c88bbf82a541c57c61.tar.gz
cpython-32ca3dcb97a75c05dc2b90c88bbf82a541c57c61.tar.bz2
cpython-32ca3dcb97a75c05dc2b90c88bbf82a541c57c61.zip
Issue #23099: Closing io.BytesIO with exported buffer is rejected now to
prevent corrupting exported buffer.
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r--Lib/_pyio.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index 36146449375..98b87f74824 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -852,8 +852,14 @@ class BytesIO(BufferedIOBase):
def getbuffer(self):
"""Return a readable and writable view of the buffer.
"""
+ if self.closed:
+ raise ValueError("getbuffer on closed file")
return memoryview(self._buffer)
+ def close(self):
+ self._buffer.clear()
+ super().close()
+
def read(self, size=None):
if self.closed:
raise ValueError("read from closed file")