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

Tim Peters tim_one@email.msn.com
Sun, 6 Apr 2003 21:11:10 -0400


[Jim Fulton]
> If I understand the problem, it can be avoided by avoiding
> old-style classes.

In Python 2.3, that appears to be true.  In Python 2.2.2, not true.  The
problems are caused by __getattr__ hooks that resurrect unreachable objects,
and/or remove the last reference to an unreachable object, when such a hook
is on an instance reachable only from an unreachable cycle, and the class
doesn't explicitly define a __del__ method, and the class has a getattr
hook, and the getattr hook does extreme things instead of just saying "no,
there's no __del__ here".

Python 2.3 introduced new machinery for new-style classes specifically aimed
at answering the "does it support __del__?" question without invoking
getattr hooks, and that's why it's not a problem for new-style classes in
2.3.  New-style classes still go thru getattr hooks to answer this question
in 2.2.2.

There were problem in Python and problems in Zope here.  Jeremy fixed the
Zope problems under 2.2 by breaking the

    and the getattr hook does extreme things instead of just saying "no,
    there's no __del__ here"

link of the chain for persistent objects.

> Maybe it's time to, at least optionally, cause a warning when
> old-style classes are used. :)  I'm not kidding for Zope. I think it
> might be worth-while to be issue such a warning in Zope.

There may be good reasons for wanting that, but none raised in this thread
so far are relevant (unless 2.3 is mandated for Zope, which I'm sure we
don't want to do).