Skip to content

Commit

Permalink
Document PyObject_ClearWeakRefs
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Mar 11, 2023
1 parent b97f25b commit 1465769
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Doc/c-api/weakref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,13 @@ as much as it can.
.. c:function:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
Similar to :c:func:`PyWeakref_GetObject`, but does no error checking.
.. c:function:: void PyObject_ClearWeakRefs(PyObject *object)
This function is called by the :c:member:`~PyTypeObject.tp_dealloc` handler
to clear weak references.
This iterates through the weak references for *object* and calls callbacks
for those references which have one. It returns when all callbacks have
been attempted.
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ Porting to Python 3.12
Classes declaring :const:`Py_TPFLAGS_MANAGED_DICT` should call
:c:func:`!_PyObject_VisitManagedDict` and :c:func:`!_PyObject_ClearManagedDict`
to traverse and clear their instance's dictionaries.
To clear weakrefs, call :c:func:`!PyObject_ClearWeakRefs`, as before.
To clear weakrefs, call :c:func:`PyObject_ClearWeakRefs`, as before.

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

0 comments on commit 1465769

Please sign in to comment.