[Python-Dev] Re: [PythonLabs] Re: [Python-checkins] python/dist/src/Modules gcmodule.c,,

Jeremy Hylton jeremy@zope.com
04 Apr 2003 15:15:51 -0500

We've got the first version of boom nailed, but we've got the same
problem in handle_finalizers().  The version of boom below doesn't blow
up until the second time the has_finalizer() is called.

I don't understand the logic in handle_finalizers(), though.  If the
objects are all in the finalizers list, why do we call has_finalizer() a
second time?  Shouldn't everything has a finalizer at that point?


import gc

class C:

    def __init__(self):
        self.x = 0

    def delete(self):
        print "never called"
    def __getattr__(self, attr):
        self.x += 1
        print self.x
        if self.x > 1:
            del self.attr
            return self.delete
        raise AttributeError

a = C()
b = C()
a.attr = b
b.attr = a

del a, b
print gc.collect()