[Python-Dev] Re: More fun with Python shutdown

Tim Peters tim at zope.com
Tue Nov 11 23:17:59 EST 2003

>> >>> class C(object): pass
>> ..
>> >>> object.__subclasses__()[-1]  # so C is reachable from object
>> >>> <class '__main__.C'>

[Phillip J. Eby]
> I thought this was done with weak references.

Ouch, yes.  My apologies -- I keep forgetting that one.

>> For that matter, since the first element of the MRO is the class
>> itself [self-cycle]

> Oops.  I forgot about that.

OK, I'll settle for a tie in the forgetfulness contest <wink>.

> Hm.  So what if tp_clear didn't mess with the MRO, except to decref
> its self-reference in the MRO?  tp_dealloc would have to decref the
> MRO tuple then, and deal with the off-by-one refcount for the type
> that would result from the tuple's deallocation.  Could that work?

Until we have a finite test case that reproduces Jim's problem, I don't
know.  It's possible.  My intuition remains that hacking the tp_mro slot is
patching a symptom of a deeper problem that's going to keep coming back in
other guises.

BTW, lying about true refcounts is fraught with subtle dangers.  If you were
the one who had to fiddle the ZODB3 cache to work with Python's cyclic gc,
you'd have a better gut appreciation for that <wink>.

More information about the Python-Dev mailing list