New submission from Alex Waygood <alex.wayg...@gmail.com>:

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.

----------
messages: 408898
nosy: AlexWaygood, ethan.furman
priority: normal
severity: normal
status: open
title: Attempting to create an enum with slots silently fails
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46132>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to