mirror of
https://github.com/python/cpython.git
synced 2025-09-15 05:06:12 +00:00
gh-100098: [Enum] insist on actual tuples, no subclasses, for auto (GH-100099)
When checking for auto() instances, only top-level usage is supported,
which means either alone or as part of a regular tuple. Other
containers, such as lists, dicts, or namedtuples, will not have auto()
transformed into a value.
(cherry picked from commit ded02ca54d
)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
This commit is contained in:
parent
846898e5ab
commit
d4426c8295
3 changed files with 17 additions and 1 deletions
|
@ -430,7 +430,9 @@ class _EnumDict(dict):
|
|||
if isinstance(value, auto):
|
||||
single = True
|
||||
value = (value, )
|
||||
if isinstance(value, tuple):
|
||||
if type(value) is tuple and any(isinstance(v, auto) for v in value):
|
||||
# insist on an actual tuple, no subclasses, in keeping with only supporting
|
||||
# top-level auto() usage (not contained in any other data structure)
|
||||
auto_valued = []
|
||||
for v in value:
|
||||
if isinstance(v, auto):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue