Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -4071,8 +4071,6 @@ type_dealloc_common(PyTypeObject *type)
remove_all_subclasses(type, type->tp_bases);
PyErr_Restore(tp, val, tb);
}

PyObject_ClearWeakRefs((PyObject *)type);
}


Expand All @@ -4094,19 +4092,29 @@ _PyStaticType_Dealloc(PyTypeObject *type)
Py_CLEAR(type->tp_cache);
// type->tp_subclasses is NULL

// PyObject_ClearWeakRefs() raises an exception if Py_REFCNT() != 0
if (Py_REFCNT(type) == 0) {
PyObject_ClearWeakRefs((PyObject *)type);
}

type->tp_flags &= ~Py_TPFLAGS_READY;
}


static void
type_dealloc(PyTypeObject *type)
{
/* Assert this is a heap-allocated type object */
// Assert this is a heap-allocated type object
_PyObject_ASSERT((PyObject *)type, type->tp_flags & Py_TPFLAGS_HEAPTYPE);

_PyObject_GC_UNTRACK(type);

type_dealloc_common(type);

// PyObject_ClearWeakRefs() raises an exception if Py_REFCNT() != 0
assert(Py_REFCNT(type) == 0);
PyObject_ClearWeakRefs((PyObject *)type);

Py_XDECREF(type->tp_base);
Py_XDECREF(type->tp_dict);
Py_XDECREF(type->tp_bases);
Expand Down