Issue1267884
Created on 2005-08-24 10:22 by rodrigo_rc, last changed 2007-09-07 03:38 by brett.cannon. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg26111 - (view) | Author: rodrigo (rodrigo_rc) | Date: 2005-08-24 10:22 | |
The following code eats all stack space and crashes,
both in Windows and Linux:
------------8<-------------
class C:
def __getattr__(self, a):
return object.__getattribute__(self, a)
c = C()
str(c)
------------8<-------------
It shoud probably raise "RuntimeError: maximum
recursion depth exceeded" or similar instead.
|
|||
| msg26112 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2005-09-01 20:35 | |
Logged In: YES user_id=593130 I believe this is essentially the same as open bug [ 1202533 ] a bunch of infinite C recursions Closing as duplicate and adding note to 1202533. Reopen if a fix to the above, if and when there is one, does not fix this. |
|||
| msg26113 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2005-09-01 20:37 | |
Logged In: YES user_id=593130 I believe this is essentially the same as open bug [ 1202533 ] a bunch of infinite C recursions Closing as duplicate and adding a cross-reference note to 1202533. Reopen if a fix to the above, if and when there is one, does not fix this. |
|||
| msg26114 - (view) | Author: Armin Rigo (arigo) * ![]() |
Date: 2005-09-02 09:40 | |
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-09-07 03:38:05 | brett.cannon | set | superseder: a bunch of infinite C recursions |
| 2005-08-24 10:22:04 | rodrigo_rc | create | |
