[IronPython] Class with slots and getattr not compatible

Dino Viehland dinov at exchange.microsoft.com
Tue Nov 28 20:22:21 CET 2006


Thanks for the bug report!

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Patrick O'Brien
Sent: Monday, November 20, 2006 4:36 PM
To: users at lists.ironpython.com
Subject: [IronPython] Class with slots and getattr not compatible

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/20061128/f9f814d8/attachment.html>


More information about the Ironpython-users mailing list