[IronPython] Class with slots and getattr not compatible

Patrick O'Brien sum.ergo.code at gmail.com
Tue Nov 21 01:35:38 CET 2006


Ticket:
http://www.codeplex.com/WorkItem/View.aspx?ProjectName=IronPython&WorkItemId=5801


IronPython:

>>> class Foo(object):
...     __slots__ = ['bar']
...     def __getattr__(self, name):
...         return name.upper()
...
>>> foo = Foo()
>>> foo.bar
Traceback (most recent call last):
  File , line 0, in <stdin>##2163
  File , line 0, in get_bar##2164
AttributeError: '<class '__main__.Foo'>' object has no attribute 'bar'
>>> foo.baz
'BAZ'
>>>


CPython:

PyCrust 0.9.5 - The Flakiest Python Shell
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo(object):
...     __slots__ = ['bar']
...     def __getattr__(self, name):
...         return name.upper()
...
>>> foo = Foo()
>>> foo.bar
'BAR'
>>> foo.baz
'BAZ'
>>>


-- 
Patrick K. O'Brien
Orbtech       http://www.orbtech.com
Schevo        http://www.schevo.org
Louie         http://www.pylouie.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20061120/a1fe9b01/attachment.html>


More information about the Ironpython-users mailing list