This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author loewis
Recipients Robin.Schreiber, asvetlov, gregory.p.smith, gstein, loewis, pitrou
Date 2012-08-17.17:30:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Antoine: Py_DECREF calls tp_dealloc directly, so the type needs to be DECREFed in the course of tp_dealloc. I don't think there is any alternative to that.

One may wonder why regular extension types don't do that: this is because of a hack that excludes static (non-heap) types from being reference counted in their instances. Heap types do refcount their types, consequently, subtype_dealloc also DECREFs the type.

I certainly agree that this is muddy, in particular when it comes to subtyping where the derived subtype calls the base tp_dealloc. In an ideal world, object_dealloc would decref the type, and subtypes would be required to call the base type's dealloc. However, I feel that this cannot be changed before Python 4.

So I'd propose that it is actually the leaf subtype which decrefs ob_type. The check whether you are the leaf type is then done by checking whether tp_dealloc is the one you are "in" right now.
Date User Action Args
2012-08-17 17:30:30loewissetrecipients: + loewis, gstein, gregory.p.smith, pitrou, asvetlov, Robin.Schreiber
2012-08-17 17:30:30loewissetmessageid: <>
2012-08-17 17:30:29loewislinkissue15653 messages
2012-08-17 17:30:29loewiscreate