Skip to content

Commit b187a44

Browse files
committed
Document PyObject_ClearWeakRefs
1 parent b97f25b commit b187a44

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Doc/c-api/weakref.rst

+10
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,13 @@ as much as it can.
6767
.. c:function:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
6868
6969
Similar to :c:func:`PyWeakref_GetObject`, but does no error checking.
70+
71+
72+
.. c:function:: void PyObject_ClearWeakRefs(PyObject *ob)
73+
74+
This function is called by the :c:member:`~PyTypeObject.tp_dealloc` handler
75+
to clear weak references.
76+
77+
This iterates through the weak references for *ob* and calls callbacks
78+
for those references which have one. It returns when all callbacks have
79+
been attempted.

Doc/whatsnew/3.12.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ Porting to Python 3.12
960960
Classes declaring :const:`Py_TPFLAGS_MANAGED_DICT` should call
961961
:c:func:`!_PyObject_VisitManagedDict` and :c:func:`!_PyObject_ClearManagedDict`
962962
to traverse and clear their instance's dictionaries.
963-
To clear weakrefs, call :c:func:`!PyObject_ClearWeakRefs`, as before.
963+
To clear weakrefs, call :c:func:`PyObject_ClearWeakRefs`, as before.
964964

965965
* The :c:func:`PyUnicode_FSDecoder` function no longer accepts bytes-like
966966
paths, like :class:`bytearray` and :class:`memoryview` types: only the exact

0 commit comments

Comments
 (0)