mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #23099: Closing io.BytesIO with exported buffer is rejected now to
prevent corrupting exported buffer.
This commit is contained in:
parent
b5e8e57555
commit
c057c3859c
5 changed files with 23 additions and 7 deletions
|
@ -398,14 +398,19 @@ class BytesIOMixin:
|
|||
# raises a BufferError.
|
||||
self.assertRaises(BufferError, memio.write, b'x' * 100)
|
||||
self.assertRaises(BufferError, memio.truncate)
|
||||
self.assertRaises(BufferError, memio.close)
|
||||
self.assertFalse(memio.closed)
|
||||
# Mutating the buffer updates the BytesIO
|
||||
buf[3:6] = b"abc"
|
||||
self.assertEqual(bytes(buf), b"123abc7890")
|
||||
self.assertEqual(memio.getvalue(), b"123abc7890")
|
||||
# After the buffer gets released, we can resize the BytesIO again
|
||||
# After the buffer gets released, we can resize and close the BytesIO
|
||||
# again
|
||||
del buf
|
||||
support.gc_collect()
|
||||
memio.truncate()
|
||||
memio.close()
|
||||
self.assertRaises(ValueError, memio.getbuffer)
|
||||
|
||||
|
||||
class PyBytesIOTest(MemoryTestMixin, MemorySeekTestMixin,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue