[issue12766] strange interaction between __slots__ and class-level attributes

Antoine Pitrou report at bugs.python.org
Wed Aug 17 01:13:13 CEST 2011


Antoine Pitrou <pitrou at free.fr> added the comment:

> This sort of thing is true of any slotted class with class attributes:
> 
> >>> class X:
> ...     __slots__ = ()
> ...     foo = None
> ... 
> >>> X().foo = "hello"
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> AttributeError: 'X' object attribute 'foo' is read-only

But that's quite different. In your example, the attribute can't be set
on the instance, while it should be in mine (since 'foo' is amongst the
__slots__).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12766>
_______________________________________


More information about the Python-bugs-list mailing list