Message168449
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:30 | loewis | set | recipients:
+ loewis, gstein, gregory.p.smith, pitrou, asvetlov, Robin.Schreiber |
2012-08-17 17:30:30 | loewis | set | messageid: <1345224630.27.0.0367899548305.issue15653@psf.upfronthosting.co.za> |
2012-08-17 17:30:29 | loewis | link | issue15653 messages |
2012-08-17 17:30:29 | loewis | create | |
|