mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-135607: remove null checking of weakref list in dealloc of extension modules and objects (#135614)
Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
0533c1faf2
commit
b1056c2a44
32 changed files with 77 additions and 83 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "pycore_object.h"
|
||||
#include "pycore_pyerrors.h"
|
||||
#include "pycore_pystate.h" // _PyThreadState_GET()
|
||||
#include "pycore_weakref.h" // FT_CLEAR_WEAKREFS()
|
||||
|
||||
|
||||
/* undefine macro trampoline to PyCFunction_NewEx */
|
||||
|
@ -167,9 +168,7 @@ meth_dealloc(PyObject *self)
|
|||
{
|
||||
PyCFunctionObject *m = _PyCFunctionObject_CAST(self);
|
||||
PyObject_GC_UnTrack(m);
|
||||
if (m->m_weakreflist != NULL) {
|
||||
PyObject_ClearWeakRefs((PyObject*) m);
|
||||
}
|
||||
FT_CLEAR_WEAKREFS(self, m->m_weakreflist);
|
||||
// We need to access ml_flags here rather than later.
|
||||
// `m->m_ml` might have the same lifetime
|
||||
// as `m_self` when it's dynamically allocated.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue