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
{{ message }}
Repository navigation
enum: Member names accidentally removed from "invalid enum member name(s)" message #93118
raiseValueError('invalid enum member name(s) '.format(
','.join(repr(n) fornininvalid_names)))
(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__returncls._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__raiseValueError('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__returncls._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__raiseValueError('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
Activity
gh-93118: [Enum] fix error message (GH-93138)
pythongh-93118: [Enum] fix error message (pythonGH-93138)
ethanfurman commentedon May 23, 2022
Fixed.
gh-93118: [Enum] fix error message (GH-93138) (GH-93142)