homepage

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 arigo
Recipients
Date 2005年09月02日.09:40:43
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=4771
This is indeed a bug similar to 1202533: the infinite
recursion is in C, and doesn't go through the user-defined
__getattr__().
The sample code snippet is definitely strange: it mixes
object.__getattribute__() with an old-style class, i.e. one
that doesn't inherit from 'object'. This code would work as
expected if C were inheriting from 'object'.
Instead, what occurs in this crash is that the __str__ of
InstanceType calls __getattr__, which calls
object.__getattribute__(c, '__str__'); the latter returns a
so-called method wrapper object, which means essentially a
method object bound to a C function. In this case the C
function is again the __str__ of InstanceType. So this
__str__ ends up calling itself infinitely.
A more direct way to expose the bug is:
from types import *
class C:
 __str__ = InstanceType.__str__
str(C())
Clearly, all special methods are affected:
class C:
 __add__ = InstanceType.__add__
C()+1
It should be fixed together with [ 1202533 ], if the latter
is ever fixed.
History
Date User Action Args
2007年08月23日 14:33:58adminlinkissue1267884 messages
2007年08月23日 14:33:58admincreate

AltStyle によって変換されたページ (->オリジナル) /