summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_buffer.py
diff options
context:
space:
mode:
authorsobolevn <mail@sobolevn.me>2024-11-19 14:44:53 (GMT)
committerGitHub <noreply@github.com>2024-11-19 14:44:53 (GMT)
commit3932e1db5353bbcf3e3c1133cc9d2cde654cb645 (patch)
tree78e55b4b13b37d7dfd45f98cb91b4682f760ab69 /Lib/test/test_buffer.py
parent4d771977b17e5ffaa9c2e8a2e6f5d393f68fc63c (diff)
downloadcpython-3932e1db5353bbcf3e3c1133cc9d2cde654cb645.zip
cpython-3932e1db5353bbcf3e3c1133cc9d2cde654cb645.tar.gz
cpython-3932e1db5353bbcf3e3c1133cc9d2cde654cb645.tar.bz2
gh-126980: Fix `bytearray.__buffer__` crash on `PyBUF_{READ,WRITE}` (#126981)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Lib/test/test_buffer.py')
-rw-r--r--Lib/test/test_buffer.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py
index 332e49c..61921e9 100644
--- a/Lib/test/test_buffer.py
+++ b/Lib/test/test_buffer.py
@@ -4439,6 +4439,14 @@ class TestBufferProtocol(unittest.TestCase):
x = ndarray([1,2,3], shape=[3], flags=ND_GETBUF_FAIL)
self.assertRaises(BufferError, memoryview, x)
+ def test_bytearray_release_buffer_read_flag(self):
+ # See https://github.com/python/cpython/issues/126980
+ obj = bytearray(b'abc')
+ with self.assertRaises(SystemError):
+ obj.__buffer__(inspect.BufferFlags.READ)
+ with self.assertRaises(SystemError):
+ obj.__buffer__(inspect.BufferFlags.WRITE)
+
@support.cpython_only
def test_pybuffer_size_from_format(self):
# basic tests