]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-128008: Add `PyWeakref_IsDead()` (GH-128009)
authorSam Gross <colesbury@gmail.com>
Thu, 19 Dec 2024 15:17:15 +0000 (10:17 -0500)
committerGitHub <noreply@github.com>
Thu, 19 Dec 2024 15:17:15 +0000 (16:17 +0100)
commit7b811d0562a0bf7433165785f1549ac199610f8b
tree75314e9af7386a3e43f724a2ef9c9203699bcbbe
parentb9b3e4a076caddf7876d1d4d762a117a26faffcf
gh-128008: Add `PyWeakref_IsDead()` (GH-128009)

The `PyWeakref_IsDead()` function tests if a weak reference is dead
without any side effects. Although you can also detect if a weak
reference is dead using `PyWeakref_GetRef()`, that function returns a
strong reference that must be `Py_DECREF()`'d, which can introduce side
effects if the last reference is concurrently dropped (at least in the
free threading build).
Doc/c-api/weakref.rst
Include/cpython/weakrefobject.h
Misc/NEWS.d/next/C_API/2024-12-16-21-59-06.gh-issue-128008.fa9Jt0.rst [new file with mode: 0644]
Modules/_testcapimodule.c
Objects/weakrefobject.c