[IronPython] Class with slots and getattr not compatible

Patrick O'Brien sum.ergo.code at gmail.com
Mon Nov 20 16:35:38 PST 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://lists.ironpython.com/pipermail/users-ironpython.com/attachments/20061120/a1fe9b01/attachment.htm


More information about the users mailing list