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 pitrou
Recipients benjamin.peterson, kristjan.jonsson, pitrou
Date 2010-03-23.15:25:38
SpamBayes Score 3.093866e-05
Marked as misclassified No
Message-id <1269357940.63.0.0128115998533.issue8212@psf.upfronthosting.co.za>
In-reply-to
Content
Indeed. The io module has had to circumvent this and uses the following snippet when resurrecting an instance of a subclass of one of its types (see iobase_dealloc() in Modules/_io/iobase.c):

        /* When called from a heap type's dealloc, the type will be
           decref'ed on return (see e.g. subtype_dealloc in typeobject.c). */
        if (PyType_HasFeature(Py_TYPE(self), Py_TPFLAGS_HEAPTYPE))
            Py_INCREF(Py_TYPE(self));
        return;


I agree it would be nice to have an automatic way of handling this. I don't see an obvious solution, though.
History
Date User Action Args
2010-03-23 15:25:40pitrousetrecipients: + pitrou, kristjan.jonsson, benjamin.peterson
2010-03-23 15:25:40pitrousetmessageid: <1269357940.63.0.0128115998533.issue8212@psf.upfronthosting.co.za>
2010-03-23 15:25:38pitroulinkissue8212 messages
2010-03-23 15:25:38pitroucreate