Skip to content

Commit

Permalink
fix: conditional decref of type for USE_HEAP_TYPES
Browse files Browse the repository at this point in the history
Fixes segfaults for Python < 3.11.
  • Loading branch information
tseaver committed May 26, 2024
1 parent be8e59b commit d5a06fc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/zope/hookable/_zope_hookable.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ hookable_init(hookable* self, PyObject* args, PyObject* kwds)
static int
hookable_traverse(hookable* self, visitproc visit, void* arg)
{
#if USE_HEAP_TYPES
#if PY_VERSION_HEX >= 0x03090000
Py_VISIT(Py_TYPE(self));
#endif
#endif
Py_VISIT(self->implementation);
Py_VISIT(self->original);
Expand Down Expand Up @@ -97,8 +99,10 @@ hookable_dealloc(hookable* self)

tp->tp_free((PyObject*)self);

#if USE_HEAP_TYPES
/* heap types must decref their type when dealloc'ed */
Py_DECREF(tp);
#endif
}

static PyObject*
Expand Down

0 comments on commit d5a06fc

Please sign in to comment.