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 amaury.forgeotdarc
Recipients amaury.forgeotdarc, dizzy, gregory.p.smith
Date 2010-12-30.12:27:21
SpamBayes Score 3.8871002e-07
Marked as misclassified No
Message-id <1293712047.23.0.81806011221.issue10794@psf.upfronthosting.co.za>
In-reply-to
Content
Normally you should never call __del__, OTOH the issue is the same with a class like::

class A:
    def close(self):
        self.close()
    def __del__(self):
        self.close()

The problem is not with _infinite_ recursion, though; a depth of 47 is enough (but 46 won't show the problem)::

class A:
    def __del__(self):
        self.recurse(47)
    def recurse(self, n):
        if n:
            self.recurse(n-1)
        else:
            raise ValueError

Hint: PyTrash_UNWIND_LEVEL is defined to 50; I checked that recompiling Python with a different value also changes the necessary recursion depth.

There is some nasty interaction between the "Trashcan mechanism" and resurrected objects stored in deep structures. A list is enough, no need to involve frames and exceptions::

class C:
    def __del__(self):
        print ".",
        x = self
        for i in range(49):    # PyTrash_UNWIND_LEVEL-1
            x = [x]
l = [C()]
del l
History
Date User Action Args
2010-12-30 12:27:27amaury.forgeotdarcsetrecipients: + amaury.forgeotdarc, gregory.p.smith, dizzy
2010-12-30 12:27:27amaury.forgeotdarcsetmessageid: <1293712047.23.0.81806011221.issue10794@psf.upfronthosting.co.za>
2010-12-30 12:27:21amaury.forgeotdarclinkissue10794 messages
2010-12-30 12:27:21amaury.forgeotdarccreate