gh-77894: Fix a crash when the GC breaks a loop containing a memoryview (GH-123898)

Now a memoryview object can only be cleared if there are no buffers
that refer it.
This commit is contained in:
Serhiy Storchaka 2024-09-11 12:05:46 +03:00 committed by GitHub
parent 00ffdf2736
commit a1dbf2ea69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 57 additions and 33 deletions

View file

@ -2323,12 +2323,10 @@ class AbstractPicklingErrorTests:
'PickleBuffer can only be pickled with protocol >= 5')
def test_non_continuous_buffer(self):
if self.pickler is pickle._Pickler:
self.skipTest('CRASHES (see gh-122306)')
for proto in protocols[5:]:
with self.subTest(proto=proto):
pb = pickle.PickleBuffer(memoryview(b"foobar")[::2])
with self.assertRaises(pickle.PicklingError):
with self.assertRaises((pickle.PicklingError, BufferError)):
self.dumps(pb, proto)
def test_buffer_callback_error(self):