Skip to content

Commit

Permalink
fix: more expliit weakref clearance
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Sep 6, 2024
1 parent 334d432 commit 7ca6275
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/zope/interface/_zope_interface_coptimizations.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ static void
OSD_dealloc(PyObject* self)
{
PyObject_GC_UnTrack(self);
PyObject_ClearWeakRefs(OBJECT(self));
PyTypeObject *tp = Py_TYPE(self);
tp->tp_free(OBJECT(self));
Py_DECREF(tp);
Expand Down Expand Up @@ -1123,6 +1124,7 @@ static void
LB_dealloc(LB* self)
{
PyObject_GC_UnTrack((PyObject*)self);
PyObject_ClearWeakRefs(OBJECT(self));
PyTypeObject* tp = Py_TYPE(self);
LB_clear(self);
tp->tp_free((PyObject*)self);
Expand Down Expand Up @@ -1710,6 +1712,7 @@ static void
VB_dealloc(VB* self)
{
PyObject_GC_UnTrack((PyObject*)self);
PyObject_ClearWeakRefs(OBJECT(self));
PyTypeObject *tp = Py_TYPE(self);
VB_clear(self);
tp->tp_free((PyObject*)self);
Expand Down

2 comments on commit 7ca6275

@davisagli
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tseaver These types only have Py_TPFLAGS_MANAGED_WEAKREF (via BASETYPE_FLAGS) when USE_EXPLICIT_WEAKREFLIST is 0 (in Python 3.12+) so we should probably also use that condition for calling PyObject_ClearWeakRefs here.

@davisagli
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tseaver Or else take Py_TPFLAGS_MANAGED_WEAKREF back out of BASETYPE_FLAGS and only add it for SpecificationBase

Please sign in to comment.