__getattr__ possible loop

2006-12-28 Thread bearophileHUGS
I have tried this, with Psyco it segfaults, and with Python 2.5 (on Win) hangs the interpreter, is it possible to improve the situation? class T(object): def __getattr__(self, x): dir(self) #import psyco #psyco.full() T().method() (Probably dir calls __getattr__). Bye, bearophile --

Re: __getattr__ possible loop

2006-12-28 Thread Maksim Kasimov
[EMAIL PROTECTED] wrote: I have tried this, with Psyco it segfaults, and with Python 2.5 (on Win) hangs the interpreter, is it possible to improve the situation? class T(object): def __getattr__(self, x): dir(self) #import psyco #psyco.full() T().method() (Probably dir calls

Re: __getattr__ possible loop

2006-12-28 Thread bearophileHUGS
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

Re: __getattr__ possible loop

2006-12-28 Thread Chris Mellon
On 28 Dec 2006 07:45:05 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] 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

Re: __getattr__ possible loop

2006-12-28 Thread Chris Mellon
On 12/28/06, Chris Mellon [EMAIL PROTECTED] wrote: On 28 Dec 2006 07:45:05 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] 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

Re: __getattr__ possible loop

2006-12-28 Thread Maksim Kasimov
[EMAIL PROTECTED] 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

Re: __getattr__ possible loop

2006-12-28 Thread Maksim Kasimov
Chris Mellon wrote: Nothing so clever. dir() eats and ignores all exceptions, so when you hit the recursion limit it eats the RecursionLimitExceeded exception and continues merrily along the way. This is probably not good behavior... class Foo: def __getattr__(self, attr):

Re: __getattr__ possible loop

2006-12-28 Thread Gabriel Genellina
At Thursday 28/12/2006 14:01, Maksim Kasimov wrote: Nothing so clever. dir() eats and ignores all exceptions, so when you hit the recursion limit it eats the RecursionLimitExceeded exception and continues merrily along the way. This is probably not good behavior... class Foo: def