summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-02-03 00:00:18 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-02-03 00:00:18 (GMT)
commitc057c3859c68f2e86c7a492ae8f8b4b3a3b136c8 (patch)
treeb3002ee88ef675225cec5abe608ab934aefc6ae4 /Lib/test
parentb5e8e5755586820a278326e2aa55b8ff755f0a59 (diff)
downloadcpython-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/test')
-rw-r--r--Lib/test/test_memoryio.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py
index 7cae8b2..9a2461d 100644
--- a/Lib/test/test_memoryio.py
+++ b/Lib/test/test_memoryio.py
@@ -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,