This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author AlexWaygood
Recipients AlexWaygood, ethan.furman
Date 2021-12-19.13:47:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1639921638.91.0.283272496595.issue46132@roundup.psfhosted.org>
In-reply-to
Content
Attempting to create an enum with __slots__ silently fails. No error is raised if __slots__ are specified, but the usual behaviour of __slots__ does not work as expected. Attributes that are not specified in __slots__ can be freely set:


>>> from enum import Enum
>>> class Color(Enum):
...     __slots__ = ()
...     RED = 0
...     BLUE = 1
...
>>> Color.RED.foo = 'bar'
>>>


Given that enums are rather special, I didn't exactly *expect* this to work -- but it might be good to raise some kind of error if a user attempts to specify __slots__, instead of having it fail silently.
History
Date User Action Args
2021-12-19 13:47:18AlexWaygoodsetrecipients: + AlexWaygood, ethan.furman
2021-12-19 13:47:18AlexWaygoodsetmessageid: <1639921638.91.0.283272496595.issue46132@roundup.psfhosted.org>
2021-12-19 13:47:18AlexWaygoodlinkissue46132 messages
2021-12-19 13:47:18AlexWaygoodcreate