mirror of
https://github.com/python/cpython.git
synced 2025-10-13 18:33:34 +00:00
gh-104371: Fix calls to __release_buffer__
while an exception is active (#104378)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
parent
ac66cc17f2
commit
a0a98ddb31
2 changed files with 25 additions and 2 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue