[Python-checkins] python/dist/src/Objects typeobject.c,2.232,2.233

Tim Peters tim_one@email.msn.com
Mon, 26 May 2003 08:16:09 -0400


[Tim]
>> inherit_slots():  Don't inherit tp_free unless the type and its base
>> agree about whether they're gc'able.  If the type is gc'able and the
>> base is not, and the base uses the default PyObject_Del for its
>> tp_free, give the type PyObject_GC_Del for its tp_free (the
>> appropriate default for a gc'able type).

[Jack Jansen]
> Is it reasonable that in the normal course of events a type and
> basetype disagree on GC'ability?

Yes, because by default all types inherit from "object", which isn't
gc'able, so by default every gc'able type disagrees with its base class
about gc'ability.  For gc'able types constructed dynamically (e.g., almost
all classes defined via Python code), Python was already inserting
PyObject_GC_Del by magic.  But it wasn't for statically defined types
written in C.  That's what the patch changed.  Jim Fulton bumped into this
when defining new gc'able types in C, and getting segfaults due to them
inheriting PyObject_Del from object.

> Because if it isn't shouldn't we print a warning or something (at
> least in debug builds)?

I'm afraid it's so common it would be viewed as a nuisance complaint.