-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
Closed
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
Bug report
I have this (simplified) code
from enum import Enum, auto, unique
@unique
class TokenType(Enum):
# // Single-character tokens.
LEFT_PAREN = '('
# // Literals.
IDENTIFIER = auto()
STRING = auto()
NUMBER = auto()
# // Keywords.
AND = 'and'
WHILE = 'while'
EOF = auto()I tested this (I developed it) using python 3.10.8.
My friend ran it in 3.11.3 and it breaks like this:
File ".../3.11.3/lib/python3.11/enum.py", line 1561, in unique
raise ValueError('duplicate values found in %r: %s' %
ValueError: duplicate values found in <enum 'TokenType'>: NUMBER -> STRING, EOF -> STRING
We can work around the problem using a StrEnum and it's all fine. But I think this is a regression bug. I don't think my code should break like this because the standard library changed.
Also, fyi, StrEnum is new in 3.11 so I cannot just adjust my own code (which works well).
Linked PRs
Metadata
Metadata
Assignees
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