__getattr__ possible loop

Maksim Kasimov maksim.kasimov at gmail.com
Thu Dec 28 11:50:18 EST 2006


bearophileHUGS at lycos.com wrote:
> Maksim Kasimov:
>> how to improve the situation depends on what do you expect to get by calling "T().method()"
> 
> You are right, sorry for being cryptic. I think that's a kind of bug of
> Python (produced maybe by an infinite loop), so an improvement can be a
> traceback or some automatic breaking of that loop. Note that my problem
> comes from using Psyco that segfaults in that situation (if you have
> Psyco installed you can decomment two lines to see that). I think that
> using normal code Python+Psyco don't have to segfault, but I know this
> is tricky situation, so if no simple "solutions" can be found, then
> it's not a important thing and it can be ignored.
> 
> Bye,
> bearophile
> 

it is neither a bug of python neither it comes from using Psyco,
the problem is here:
	def __getattr__(self, x): dir(self)

the "__getattr__" method calls "dir",
but then "dir" calls "__getattr__" method of the object (self) - it makes endless loop


(see the code in my previous message)


-- 
Maksim Kasimov



More information about the Python-list mailing list