Re: [IronPython] __getattribute__ bug
There as no answer to this - so I have raised it as codeplex issue 13820: Michael http://www.manning.com/foord On Nov 3, 12:26 am, Michael Foord [EMAIL PROTECTED] wrote: 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\cextdescriptors.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\cextC:\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... Michaelhttp://www.manning.com/foord ___ Users mailing list [EMAIL PROTECTED]://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] __getattribute__ bug
Thanks for the bug report, and sorry for missing the original mail. This is a bug in a code path that will ultimately be going away - currently we still have a mix of code paths that use the new DynamicSite and Rules mechanism and the old interface / PythonType (Formerly DynamicType) / CLR type based dispatch mechanism. As we finish the switch over to rules the bug will be fixed by re-writing that code path. It might take a little while before we get there though :(. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Foord Sent: Monday, November 12, 2007 6:08 AM To: users@lists.ironpython.com Subject: Re: [IronPython] __getattribute__ bug There as no answer to this - so I have raised it as codeplex issue 13820: Michael http://www.manning.com/foord On Nov 3, 12:26 am, Michael Foord [EMAIL PROTECTED] wrote: 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\cextdescriptors.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\cextC:\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... Michaelhttp://www.manning.com/foord ___ Users mailing list [EMAIL PROTECTED]://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] __getattribute__ bug
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\cextdescriptors.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\cextC:\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