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

Benjamin Peterson report at bugs.python.org
Wed Aug 17 01:09:33 CEST 2011


Benjamin Peterson <benjamin at python.org> 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

I think what needs to happen is the error message needs to be improved in both cases.

----------

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


More information about the Python-bugs-list mailing list