Hello all,

A bug in '__getattribute__' - magic methods should be fetched from the 
class and not go through '__getattribute__'.

This is making a proxy class I'm writing behave very oddly:

The following code:

def DoNothing(*args):
    pass

class Something(object):
    def __getattribute__(self, name):
        print name
        return DoNothing
       
    def __call__(self):
        print 'called'
       
    def __getitem__(self, name):
        raise Exception('w00t!')

    def __setitem__(self, name, value):
        raise Exception('w00t!')
   
s = Something()
s['fish'] = 3


Does this on CPython:

C:\compile\cext\trunk\cext>descriptors.py
Traceback (most recent call last):
  File "C:\compile\cext\trunk\cext\descriptors.py", line 20, in ?
    s['fish'] = 3
  File "C:\compile\cext\trunk\cext\descriptors.py", line 17, in __setitem__
    raise Exception('w00t!')
Exception: w00t!


And this on IronPython 2a5:

C:\compile\cext\trunk\cext>C:\compile\IronPython2\ipy.exe -D 
-X:TabCompletion -X
:ColorfulConsole descriptors.py
__setitem__


To make things odder - if the class 'Something' doesn't have a 
__setitem__ method then an attribute error is correctly raised. For 
'__call__' I am *sometimes* seeing that go through '__getattribute__' 
and sometimes not...

Michael
http://www.manning.com/foord

_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to