[IronPython] Overloading __getattr__
Dino Viehland
dinov at exchange.microsoft.com
Fri Jun 16 09:34:23 PDT 2006
Thanks for the bug report - this is fixed for the next release (the actual problem here is we were looking for instance members for special methods, which we shouldn't do). You can actually get the fix now if you get the latest bits from IronPython on http://www.codeplex.com, but we should have a release real soon now.
-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: Friday, June 16, 2006 8:03 AM
To: Discussion of IronPython
Subject: [IronPython] Overloading __getattr__
Hello all,
We have a problem with IronPython and overloading __getattr__, and use of the python magic methods (double underscore).
To illustrate the problem :
class Test(object):
def __getattr__(self, name):
print name
raise AttributeError("Go Away")
if Test():
print "Hello"
On CPython it does this :
Hello
On IronPython :
__nonzero__
Traceback (most recent call last):
File C:\Personal\Python Projects\modules in progress\ironpython\test.py, line 6, in Initialize
File C:\Personal\Python Projects\modules in progress\ironpython\test.py, line 4, in __getattr__
AttributeError: Go Away
We are trying to overload __getattr__ and getting calls to __hash__, __len__, __gt__ etc sent there in various places.
All the best,
Michael Foord
http://www.resolversystems.com
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
More information about the users
mailing list