diff options
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 2 | ||||
-rw-r--r-- | Objects/weakrefobject.c | 12 |
2 files changed, 11 insertions, 3 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 5c490e8..5bf2bc2 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2369,7 +2369,7 @@ subtype_dealloc(PyObject *self) finalizers since they might rely on part of the object being finalized that has already been destroyed. */ if (type->tp_weaklistoffset && !base->tp_weaklistoffset) { - _PyWeakref_ClearWeakRefsExceptCallbacks(self); + _PyWeakref_ClearWeakRefsNoCallbacks(self); } } diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index 3b027e1..0fcd37d 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -1016,7 +1016,7 @@ PyObject_ClearWeakRefs(PyObject *object) PyObject *exc = PyErr_GetRaisedException(); PyObject *tuple = PyTuple_New(num_weakrefs * 2); if (tuple == NULL) { - _PyWeakref_ClearWeakRefsExceptCallbacks(object); + _PyWeakref_ClearWeakRefsNoCallbacks(object); PyErr_WriteUnraisable(NULL); PyErr_SetRaisedException(exc); return; @@ -1057,6 +1057,14 @@ PyObject_ClearWeakRefs(PyObject *object) PyErr_SetRaisedException(exc); } +void +PyUnstable_Object_ClearWeakRefsNoCallbacks(PyObject *obj) +{ + if (_PyType_SUPPORTS_WEAKREFS(Py_TYPE(obj))) { + _PyWeakref_ClearWeakRefsNoCallbacks(obj); + } +} + /* This function is called by _PyStaticType_Dealloc() to clear weak references. * * This is called at the end of runtime finalization, so we can just @@ -1076,7 +1084,7 @@ _PyStaticType_ClearWeakRefs(PyInterpreterState *interp, PyTypeObject *type) } void -_PyWeakref_ClearWeakRefsExceptCallbacks(PyObject *obj) +_PyWeakref_ClearWeakRefsNoCallbacks(PyObject *obj) { /* Modeled after GET_WEAKREFS_LISTPTR(). |