You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PyObject_CallFinalizerFromDealloc is undocumented #75459
It's unclear if PyObject_CallFinalizerFromDealloc is a public function
or not. It is not documented, but it seems there's no other way to
ensure that tp_finalize runs, at least for objects without
Py_TPFLAGS_HAVE_GC.
"""It is called either from the garbage collector (if the instance is
part of an isolated reference cycle) or just before the object is
deallocated."""
However, it appears it is necessary to call it explicitly from any
user-provided tp_dealloc. Indeed, there are several calls to
PyObject_CallFinalizerFromDealloc in cpython/Modules/* e.g. in
posixmodule.c:ScandirIterator_dealloc
Activity
pv commentedon Aug 25, 2017
It's unclear if PyObject_CallFinalizerFromDealloc is a public function
or not. It is not documented, but it seems there's no other way to
ensure that tp_finalize runs, at least for objects without
Py_TPFLAGS_HAVE_GC.
In the documentation of tp_finalize (https://docs.python.org/3/c-api/typeobj.html?highlight=tp_finalize#c.PyTypeObject.tp_finalize)
there is the sentence:
"""It is called either from the garbage collector (if the instance is
part of an isolated reference cycle) or just before the object is
deallocated."""
However, it appears it is necessary to call it explicitly from any
user-provided tp_dealloc. Indeed, there are several calls to
PyObject_CallFinalizerFromDealloc in cpython/Modules/* e.g. in
posixmodule.c:ScandirIterator_dealloc
pythongh-75459: Doc: C API: Improve object life cycle documentation
pythongh-75459: Doc: C API: Improve object life cycle documentation
pythongh-75459: Doc: C API: Improve object life cycle documentation
pythongh-75459: Doc: C API: Improve object life cycle documentation
pythongh-75459: Doc: C API: Improve object life cycle documentation
pythongh-75459: Doc: C API: Improve object life cycle documentation
pythongh-75459: Doc: C API: Improve object life cycle documentation
pythongh-75459: Doc: Tell sphinx to run graphviz
Revert "pythongh-75459: Doc: Tell sphinx to run graphviz"
gh-75459: Doc: C API: Improve object life cycle documentation (GH-125962
5 remaining items
pythongh-75459: Doc: C API: Improve object life cycle documentation (p…
[3.14] gh-75459: Doc: C API: Improve object life cycle documentation (G…
pythongh-75459: Doc: C API: Improve object life cycle documentation (p…
pythongh-75459: Doc: C API: Improve object life cycle documentation (p…
pythongh-75459: versionadded for PyObject_CallFinalizer*() API
gh-75459: versionadded for PyObject_CallFinalizer*() API (GH-143982)
pythongh-75459: versionadded for PyObject_CallFinalizer*() API (pytho…
[3.14] gh-75459: versionadded for PyObject_CallFinalizer*() API (GH-1…
pythongh-75459: versionadded for PyObject_CallFinalizer*() API (pytho…