static void __Pyx_Generator_dealloc(PyObject *self) { __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; PyObject_GC_UnTrack(gen); if (gen->gi_weakreflist != NULL) PyObject_ClearWeakRefs(self); if (gen->resume_label > 0) { // Generator is paused, so we need to close PyObject_GC_Track(self); #if PY_VERSION_HEX >= 0x030400a1 if (PyObject_CallFinalizerFromDealloc(self)) #else Py_TYPE(gen)->tp_del(self); if (self->ob_refcnt > 0) #endif { // resurrected. :( return; } PyObject_GC_UnTrack(self); } __Pyx_Generator_clear(self); PyObject_GC_Del(gen); }
int _PyIOBase_finalize(PyObject *self) { int is_zombie; /* If _PyIOBase_finalize() is called from a destructor, we need to resurrect the object as calling close() can invoke arbitrary code. */ is_zombie = (Py_REFCNT(self) == 0); if (is_zombie) return PyObject_CallFinalizerFromDealloc(self); else { PyObject_CallFinalizer(self); return 0; } }
static void gen_dealloc(PyGenObject *gen) { PyObject *self = (PyObject *) gen; _PyObject_GC_UNTRACK(gen); if (gen->gi_weakreflist != NULL) PyObject_ClearWeakRefs(self); _PyObject_GC_TRACK(self); if (PyObject_CallFinalizerFromDealloc(self)) return; /* resurrected. :( */ _PyObject_GC_UNTRACK(self); Py_CLEAR(gen->gi_frame); Py_CLEAR(gen->gi_code); Py_CLEAR(gen->gi_name); Py_CLEAR(gen->gi_qualname); PyObject_GC_Del(gen); }