Message124915
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 |
|
Date |
User |
Action |
Args |
2010-12-30 12:27:27 | amaury.forgeotdarc | set | recipients:
+ amaury.forgeotdarc, gregory.p.smith, dizzy |
2010-12-30 12:27:27 | amaury.forgeotdarc | set | messageid: <1293712047.23.0.81806011221.issue10794@psf.upfronthosting.co.za> |
2010-12-30 12:27:21 | amaury.forgeotdarc | link | issue10794 messages |
2010-12-30 12:27:21 | amaury.forgeotdarc | create | |
|