mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #23099: Closing io.BytesIO with exported buffer is rejected now to
prevent corrupting exported buffer.
This commit is contained in:
commit
32ca3dcb97
5 changed files with 23 additions and 7 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue