Martin v. Löwis added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15653>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to