GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `enum`: Member names accidentally removed from "invalid enum member name(s)" message · Issue #93118 · python/cpython

enum: Member names accidentally removed from "invalid enum member name(s)" message #93118

New issue
Copy link
New issue
Copy link
Closed
Closed
enum: Member names accidentally removed from "invalid enum member name(s)" message#93118
Copy link
Assignees
ethanfurman
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@The-Compiler
The-Compiler
opened on May 23, 2022
Issue body actions

Bug report

In acf7403 (#30582), @ethanfurman changed the "Invalid enum member name" error message to "invalid enum member name(s)":

cpython/Lib/enum.py

Lines 482 to 484 in b2694ab

if invalid_names:
raise ValueError('invalid enum member name(s) '.format(
','.join(repr(n) for n in invalid_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__
    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

Activity

  1. The-Compiler
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on May 23, 2022
  2. AlexWaygood
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    3.11only security fixesonly security fixes
    3.12only security fixesonly security fixes
    on May 23, 2022
  3. AlexWaygood
    assigned
    ethanfurman
    on May 23, 2022
  4. ethanfurman
    added a commit that references this issue on May 23, 2022

    gh-93118: [Enum] fix error message (GH-93138)

    a49721e
  5. miss-islington
    added a commit that references this issue on May 23, 2022

    pythongh-93118: [Enum] fix error message (pythonGH-93138)

    324a9f0
  6. ethanfurman commented on May 23, 2022

    @ethanfurman
    ethanfurman
    on May 23, 2022
    Member
    More actions

    Fixed.

    Reacted by Freya Bruhin
  7. ethanfurman
    closed this as completedon May 23, 2022
  8. ethanfurman
    added a commit that references this issue on May 23, 2022

    gh-93118: [Enum] fix error message (GH-93138) (GH-93142)

    b8c4cc6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @ethanfurman
    ethanfurman

Labels

3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.