Closed
Description
Bug report
In acf7403 (#30582), @ethanfurman changed the "Invalid enum member name" error message to "invalid enum member name(s)":
Lines 482 to 484 in b2694ab
(This was later reverted in 42a64c0 and reintroduced in 83d544b, but I believe the code to be the same).
However, the commit also removed {0}
from the format string, thus removing the invalid names from the error messages. As a result, the error message is now less descriptive:
$ python3.10 -c "import enum; enum.Enum('A', ['mro'])"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.10/enum.py", line 387, in __call__
return cls._create_(
File "/usr/lib/python3.10/enum.py", line 518, in _create_
enum_class = metacls.__new__(metacls, class_name, bases, classdict)
File "/usr/lib/python3.10/enum.py", line 208, in __new__
raise ValueError('Invalid enum member name: {0}'.format(
ValueError: Invalid enum member name: mro
$ python3.11 -c "import enum; enum.Enum('A', ['mro'])"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.11/enum.py", line 791, in __call__
return cls._create_(
^^^^^^^^^^^^^
File "/usr/lib/python3.11/enum.py", line 966, in _create_
return metacls.__new__(metacls, class_name, bases, classdict, boundary=boundary)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/enum.py", line 483, in __new__
raise ValueError('invalid enum member name(s) '.format(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid enum member name(s)
Given that the .format()
is still there, I'm assuming that was an accident.
(Found by running flake8
over Lib/
out of curiosity, see #93010 (comment))
Your environment
- CPython versions tested on: Python 3.11.0b1
- Operating system and architecture: Archlinux x86_64