Message408898
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. |
|
Date |
User |
Action |
Args |
2021-12-19 13:47:18 | AlexWaygood | set | recipients:
+ AlexWaygood, ethan.furman |
2021-12-19 13:47:18 | AlexWaygood | set | messageid: <1639921638.91.0.283272496595.issue46132@roundup.psfhosted.org> |
2021-12-19 13:47:18 | AlexWaygood | link | issue46132 messages |
2021-12-19 13:47:18 | AlexWaygood | create | |
|