aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Objects/methodobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/methodobject.c')
-rw-r--r--Objects/methodobject.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index 8b28662631b..e6e469ca270 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -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 */
@@ -166,13 +167,8 @@ static void
meth_dealloc(PyObject *self)
{
PyCFunctionObject *m = _PyCFunctionObject_CAST(self);
- // The Py_TRASHCAN mechanism requires that we be able to
- // call PyObject_GC_UnTrack twice on an object.
PyObject_GC_UnTrack(m);
- Py_TRASHCAN_BEGIN(m, meth_dealloc);
- 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.
@@ -190,7 +186,6 @@ meth_dealloc(PyObject *self)
assert(Py_IS_TYPE(self, &PyCFunction_Type));
_Py_FREELIST_FREE(pycfunctionobject, m, PyObject_GC_Del);
}
- Py_TRASHCAN_END;
}
static PyObject *