summaryrefslogtreecommitdiffstats
path: root/Include/cpython
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-06-18 13:57:23 (GMT)
committerGitHub <noreply@github.com>2024-06-18 13:57:23 (GMT)
commite8752d7b80775ec2a348cd4bf38cbe26a4a07615 (patch)
treeaf381ff07ef5c47aa18731fb03d5eb88452a3189 /Include/cpython
parent360f14a493d8461d42dc646be40b4b6fb20db57a (diff)
downloadcpython-e8752d7b80775ec2a348cd4bf38cbe26a4a07615.zip
cpython-e8752d7b80775ec2a348cd4bf38cbe26a4a07615.tar.gz
cpython-e8752d7b80775ec2a348cd4bf38cbe26a4a07615.tar.bz2
gh-118789: Add `PyUnstable_Object_ClearWeakRefsNoCallbacks` (#118807)
This exposes `PyUnstable_Object_ClearWeakRefsNoCallbacks` as an unstable C-API function to provide a thread-safe mechanism for clearing weakrefs without executing callbacks. Some C-API extensions need to clear weakrefs without calling callbacks, such as after running finalizers like we do in subtype_dealloc. Previously they could use `_PyWeakref_ClearRef` on each weakref, but that's not thread-safe in the free-threaded build. Co-authored-by: Petr Viktorin <encukou@gmail.com>
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/object.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/Include/cpython/object.h b/Include/cpython/object.h
index 0ab94e5..90cd7b5 100644
--- a/Include/cpython/object.h
+++ b/Include/cpython/object.h
@@ -288,6 +288,8 @@ PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *);
PyAPI_FUNC(void) PyObject_CallFinalizer(PyObject *);
PyAPI_FUNC(int) PyObject_CallFinalizerFromDealloc(PyObject *);
+PyAPI_FUNC(void) PyUnstable_Object_ClearWeakRefsNoCallbacks(PyObject *);
+
/* Same as PyObject_Generic{Get,Set}Attr, but passing the attributes
dict as the last parameter. */
PyAPI_FUNC(PyObject *)