Skip to content

Commit

Permalink
Several small tweaks to GC and deletion handling.
Browse files Browse the repository at this point in the history
Several places needed to, essentially, call super.
  • Loading branch information
jamadden committed Mar 17, 2020
1 parent f1a6da8 commit 6984592
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/zope/interface/_zope_interface_coptimizations.c
Expand Up @@ -330,6 +330,9 @@ Spec_clear(Spec* self)
static void
Spec_dealloc(Spec* self)
{
/* PyType_GenericAlloc that you get when you don't
specify a tp_alloc always tracks the object. */
PyObject_GC_UnTrack((PyObject *)self);
if (self->weakreflist != NULL) {
PyObject_ClearWeakRefs(OBJECT(self));
}
Expand Down Expand Up @@ -562,22 +565,24 @@ CPB_traverse(CPB* self, visitproc visit, void* arg)
{
Py_VISIT(self->_cls);
Py_VISIT(self->_implements);
return 0;
return Spec_traverse((Spec*)self, visit, arg);
}

static int
CPB_clear(CPB* self)
{
Py_CLEAR(self->_cls);
Py_CLEAR(self->_implements);
Spec_clear((Spec*)self);
return 0;
}

static void
CPB_dealloc(CPB* self)
{
PyObject_GC_UnTrack((PyObject *)self);
CPB_clear(self);
Py_TYPE(self)->tp_free(OBJECT(self));
Spec_dealloc((Spec*)self);
}

static PyMemberDef CPB_members[] = {
Expand Down Expand Up @@ -798,22 +803,23 @@ IB_traverse(IB* self, visitproc visit, void* arg)
{
Py_VISIT(self->__name__);
Py_VISIT(self->__module__);
return 0;
return Spec_traverse((Spec*)self, visit, arg);
}

static int
IB_clear(IB* self)
{
Py_CLEAR(self->__name__);
Py_CLEAR(self->__module__);
return 0;
return Spec_clear((Spec*)self);
}

static void
IB_dealloc(IB* self)
{
PyObject_GC_UnTrack((PyObject *)self);
IB_clear(self);
Py_TYPE(self)->tp_free(OBJECT(self));
Spec_dealloc((Spec*)self);
}

static PyMemberDef IB_members[] = {
Expand Down

0 comments on commit 6984592

Please sign in to comment.