You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/ethanfurman'closed_at=<Date2022-01-14.23:58:17.014>created_at=<Date2022-01-03.13:23:31.323>labels= ['type-bug', 'library', '3.10', '3.11']
title='Improve error message when attempting to extend an enum with `__call__`'updated_at=<Date2022-01-14.23:58:17.014>user='https://github.com/sobolevn'
But when we try to use A() call to do the same, where what happens:
Python 3.11.0a3+ (heads/main:8d7644fa64, Dec 30 2021, 13:00:40) [Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import enum
>>> class A(enum.Enum):
... a = 1
...
>>> B = A('B', 'b')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/sobolev/Desktop/cpython/Lib/enum.py", line 606, in __call__
return cls._create_(
^^^^^^^^^^^^^
File "/Users/sobolev/Desktop/cpython/Lib/enum.py", line 770, in _create_
_, first_enum = cls._get_mixins_(class_name, bases)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sobolev/Desktop/cpython/Lib/enum.py", line 899, in _get_mixins_
raise TypeError('Cannot extend enumerations')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Cannot extend enumerations
I propose to use the first error message in this case as well. Moreover, this behavior is not covered with tests:
AlexWaygood
changed the title
Improve error message when creating an enum with __call__
Improve error message when attempting to extend an enum with __call__Jan 3, 2022
Enum
with members #30357Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: