Skip to content

Commit e710025

Browse files
Address review: restore resurrection pattern for type watcher dealloc
1 parent f941984 commit e710025

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Objects/typeobject.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6883,6 +6883,7 @@ type_dealloc(PyObject *self)
68836883
// intact at this point (dict, bases, mro, name are all valid), so
68846884
// callbacks can safely inspect it.
68856885
if (type->tp_watched) {
6886+
_PyObject_ResurrectStart(self);
68866887
PyInterpreterState *interp = _PyInterpreterState_GET();
68876888
int bits = type->tp_watched;
68886889
int i = 0;
@@ -6900,7 +6901,9 @@ type_dealloc(PyObject *self)
69006901
i++;
69016902
bits >>= 1;
69026903
}
6903-
assert(Py_REFCNT(self) == 0);
6904+
if (_PyObject_ResurrectEnd(self)) {
6905+
return; // callback resurrected the object
6906+
}
69046907
}
69056908

69066909
_PyObject_GC_UNTRACK(type);

0 commit comments

Comments
 (0)