Issue 7338: recursive attribute -> Fatal Python error: Cannot recover from stack overflow. (original) (raw)

Created on 2009-11-17 11:01 by kaizhu, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg95381 - (view) Author: kai zhu (kaizhu) Date: 2009-11-17 11:01
Python 3.1.1 (r311:74480, Sep 13 2009, 17:17:12) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> class Foo(object): ... def __getattribute__(self, attr): ... try: return object.__getattribute__(attr) ... except: return self.x ... >>> Foo().y Fatal Python error: Cannot recover from stack overflow. Aborted $ python2.6 recovers from above w/ a RuntimeError
msg95382 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-11-17 11:10
This is normal. By doing "except: return self.x", you are reinvoking __getattribute__ as soon as the RuntimeError is raised, and forcing the interpreter into another infinite recursion.
msg150233 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-12-24 18:57
> This is normal. Can this be closed then?
msg150236 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2011-12-24 20:32
This is related to #13644.
msg150239 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-12-24 22:47
This seems to be a duplicate of 3555 and 6028. I am redirecting to the latter because is has a proposed patch.
History
Date User Action Args
2022-04-11 14:56:54 admin set github: 51587
2011-12-24 22:47:36 terry.reedy set status: open -> closedsuperseder: Interpreter aborts when chaining an infinite number of exceptionsnosy: + terry.reedymessages: + resolution: duplicatetype: crash -> behavior
2011-12-24 20:32:45 roger.serwy set nosy: + roger.serwymessages: +
2011-12-24 18:57:44 ezio.melotti set nosy: + ezio.melottimessages: + versions: + Python 3.2, Python 3.3, - Python 3.1
2009-11-17 11:10:23 pitrou set nosy: + loewis, pitroumessages: +
2009-11-17 11:01:32 kaizhu create