[Python-Dev] stack check on Unix: any suggestions?
Vladimir Marangozov
Vladimir.Marangozov@inrialpes.fr
Thu, 31 Aug 2000 17:32:29 +0200 (CEST)
Guido van Rossum wrote:
>
> Please try this again on various platforms with this version:
>
> i = 0
> class C:
> def __getattr__(self, name):
> global i
> print i
> i += 1
> return self.name # common beginners' mistake
>
> C() # This tries to get __init__, triggering the recursion
>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Are you sure?
Although strange, this is not the case and instantiating C succeeds
(try "python rec.py", where rec.py is the above code).
A closer look at the code shows that Instance_New goes on calling
getattr2 which calls class_lookup, which returns NULL, etc, etc,
but the presence of __getattr__ is not checked in this path.
--
Vladimir MARANGOZOV | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252