summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_buffer.py
diff options
context:
space:
mode:
authorJelle Zijlstra <jelle.zijlstra@gmail.com>2023-05-12 05:22:40 (GMT)
committerGitHub <noreply@github.com>2023-05-12 05:22:40 (GMT)
commita0a98ddb31591357bead4694b21717cb4034924f (patch)
tree05269c152cc5a41d126dba845faaa2f08d726657 /Lib/test/test_buffer.py
parentac66cc17f21653b66321b50d0a1f792982fca21f (diff)
downloadcpython-a0a98ddb31591357bead4694b21717cb4034924f.zip
cpython-a0a98ddb31591357bead4694b21717cb4034924f.tar.gz
cpython-a0a98ddb31591357bead4694b21717cb4034924f.tar.bz2
gh-104371: Fix calls to `__release_buffer__` while an exception is active (#104378)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_buffer.py')
-rw-r--r--Lib/test/test_buffer.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py
index 2c65ae8..94fc9d4 100644
--- a/Lib/test/test_buffer.py
+++ b/Lib/test/test_buffer.py
@@ -4749,6 +4749,19 @@ class TestPythonBufferProtocol(unittest.TestCase):
c.clear()
self.assertIs(c.buffer, None)
+ def test_release_buffer_with_exception_set(self):
+ class A:
+ def __buffer__(self, flags):
+ return memoryview(bytes(8))
+ def __release_buffer__(self, view):
+ pass
+
+ b = bytearray(8)
+ with memoryview(b):
+ # now b.extend will raise an exception due to exports
+ with self.assertRaises(BufferError):
+ b.extend(A())
+
if __name__ == "__main__":
unittest.main()