seg fault on asscessing undefined attr in __getattr__

Stephen Hansen news at myNOSPAM.org
Fri May 25 15:46:23 EDT 2001


"Oleg Broytmann" <phd at phd.fep.ru> wrote in message
news:mailman.990793725.634.python-list at python.org...
> On Fri, 25 May 2001, Stephen Hansen wrote:
> > "Oleg Broytmann" <phd at phd.fep.ru> wrote in message
> > news:mailman.990786458.26390.python-list at python.org...
> > > On Fri, 25 May 2001, Kong-Jei Kuan wrote:
> > > > hi, i am still using python 1.52, and don't know if this happens to
> > other
> > > > versions, can some verify this?
> > > >
> > > > Python 1.5.2 (#0, Dec 27 2000, 13:59:38)  [GCC 2.95.2 20000220
(Debian
> > GNU/Linux)] on linux2
> > > > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> > > > >>> class A:
> > > > ...   def __getattr__(self, name):
> > > > ...     self.x
> > > > ...
> > > > >>> a=A()
> > > > >>> a
> > > > Segmentation fault
> > >
> > >    Do you understand you've put your Python into infinite recursion?
> >
> >     Uh. How is this an infinate recursion? Going strictly by the code
above,
> > it isn't. 'a' and 'A' are entirely different objects; the former being
an
>
>    I think there was a mistyping in the original post, it should be a.x.
> Yes, I got "Segmentation fault" with 1.5.2, and "Maximum recursion depth
> reached" in 2.0 and 2.1.
>

    A_ha_. Yes, that makes more sense now. I thought it was having
difficulty just displaying the <__main__.A instnace ...> but, and couldn't
figure out why, since it ran fine on my machine.

--S





More information about the Python-list mailing list