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

2011-08-16 Thread Roundup Robot
Roundup Robot added the comment: New changeset 45b63a8a76c9 by Benjamin Peterson in branch 'default': complain when a class variable shadows a name in __slots__ (closes #12766) http://hg.python.org/cpython/rev/45b63a8a76c9 -- nosy: +python-dev resolution: -> fixed stage: -> committed/

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

2011-08-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: > I'm afraid that's not (easily) possible. Using __slots__ implicitly > gives classes attributes, so what you are seeing is the effect of > toying with that. It's not really possible to pretend there are > different attributes on the class than the descriptors.

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

2011-08-16 Thread Benjamin Peterson
Benjamin Peterson added the comment: I'm afraid that's not (easily) possible. Using __slots__ implicitly gives classes attributes, so what you are seeing is the effect of toying with that. It's not really possible to pretend there are different attributes on the class than the descriptors. We

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

2011-08-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: > So would you prefer to see > > >>> x.foo > Traceback (most recent call last): > File "", line 1, in > AttributeError: foo > >>> x.foo = 5 > >>> x.foo > 5 > ? No, I would prefer to see True >>> x.foo = 5 >>> x.foo 5 ... exactly as in the same class witho

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

2011-08-16 Thread Benjamin Peterson
Benjamin Peterson added the comment: So would you prefer to see >>> x.foo Traceback (most recent call last): File "", line 1, in AttributeError: foo >>> x.foo = 5 >>> x.foo 5 ? -- ___ Python tracker __

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

2011-08-16 Thread Antoine Pitrou
Antoine Pitrou 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 "", line 1, in > AttributeError: 'X' object att

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

2011-08-16 Thread Benjamin Peterson
Benjamin Peterson 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 "", line 1, in AttributeError: 'X' object attribute 'foo' is r

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

2011-08-16 Thread Antoine Pitrou
New submission from Antoine Pitrou : >>> class Foo: ...__slots__ = ['foo'] ...foo = None ... >>> x = Foo() >>> x.foo >>> x.foo = 5 Traceback (most recent call last): File "", line 1, in AttributeError: 'Foo' object attribute 'foo' is read-only -- components: Interpreter Core