Skip to content

Commit

Permalink
Fix Python warning about not untracked objects
Browse files Browse the repository at this point in the history
Python representations of LPC type objects inherit from the Python base
type object which does support GC. Therefore upon destruction we need
to untrack them.
  • Loading branch information
amotzkau committed Nov 19, 2023
1 parent 8ba7103 commit 85b326d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/pkg-python.c
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,8 @@ ldmud_lpctype_type_dealloc (ldmud_gc_lpctype_type_t* self)

remove_gc_lpctype_object(self);

if (Py_TYPE(self)->tp_flags & Py_TPFLAGS_HAVE_GC)
PyObject_GC_UnTrack(self);
Py_XDECREF(self->ldmud_lpctype.type_base.tp_base);
Py_XDECREF(self->ldmud_lpctype.type_base.tp_dict);
Py_XDECREF(self->ldmud_lpctype.type_base.tp_bases);
Expand Down Expand Up @@ -2128,6 +2130,8 @@ ldmud_concrete_array_type_dealloc (ldmud_concrete_array_type_t* self)
*/

{
if (Py_TYPE(self)->tp_flags & Py_TPFLAGS_HAVE_GC)
PyObject_GC_UnTrack(self);
Py_XDECREF(self->element_type);
Py_XDECREF(self->ldmud_lpctype.type_base.tp_base);
Py_XDECREF(self->ldmud_lpctype.type_base.tp_dict);
Expand Down Expand Up @@ -2400,6 +2404,8 @@ ldmud_concrete_struct_type_dealloc (ldmud_concrete_struct_type_t* self)
free_struct_name(self->name);
REMOVE_GC_OBJECT(gc_struct_type_list, self);

if (Py_TYPE(self)->tp_flags & Py_TPFLAGS_HAVE_GC)
PyObject_GC_UnTrack(self);
Py_XDECREF(self->ldmud_lpctype.type_base.tp_base);
Py_XDECREF(self->ldmud_lpctype.type_base.tp_dict);
Py_XDECREF(self->ldmud_lpctype.type_base.tp_bases);
Expand Down

0 comments on commit 85b326d

Please sign in to comment.