]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-118331: Don't raise an error if tuple allocation fails when clearing weakrefs...
authormpage <mpage@meta.com>
Mon, 29 Apr 2024 16:56:51 +0000 (09:56 -0700)
committerGitHub <noreply@github.com>
Mon, 29 Apr 2024 16:56:51 +0000 (16:56 +0000)
commit43fa76638fc75958b592096b6830c15f0afa1a73
treec65c40432a3785354cef4633c4e8fa87f7e2029d
parent444ac0b7a64ff6b6caba9c2731bd33151ce18ad1
gh-118331: Don't raise an error if tuple allocation fails when clearing weakrefs (#118338)

It's not safe to raise an exception in `PyObject_ClearWeakRefs()` if one
is not already set, since it may be called by `_Py_Dealloc()`, which
requires that the active exception does not change.

Additionally, make sure we clear the weakrefs even when tuple allocation
fails.
Lib/test/test_weakref.py
Objects/weakrefobject.c