diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-03 00:00:18 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-03 00:00:18 (GMT) |
commit | c057c3859c68f2e86c7a492ae8f8b4b3a3b136c8 (patch) | |
tree | b3002ee88ef675225cec5abe608ab934aefc6ae4 /Lib/_pyio.py | |
parent | b5e8e5755586820a278326e2aa55b8ff755f0a59 (diff) | |
download | cpython-c057c3859c68f2e86c7a492ae8f8b4b3a3b136c8.zip cpython-c057c3859c68f2e86c7a492ae8f8b4b3a3b136c8.tar.gz cpython-c057c3859c68f2e86c7a492ae8f8b4b3a3b136c8.tar.bz2 |
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.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 01683f8..577b600 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -833,8 +833,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") |