summaryrefslogtreecommitdiffstats
path: root/Lib/enum.py
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2022-12-08 06:58:08 (GMT)
committerGitHub <noreply@github.com>2022-12-08 06:58:08 (GMT)
commitded02ca54d7bfa32c8eab0871d56e4547cd356eb (patch)
tree3f4b0be649ed020c55b47a9dd5e7204fa12820b9 /Lib/enum.py
parentcce836296016463032495c6ca739ab469ed13d3c (diff)
downloadcpython-ded02ca54d7bfa32c8eab0871d56e4547cd356eb.zip
cpython-ded02ca54d7bfa32c8eab0871d56e4547cd356eb.tar.gz
cpython-ded02ca54d7bfa32c8eab0871d56e4547cd356eb.tar.bz2
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.
Diffstat (limited to 'Lib/enum.py')
-rw-r--r--Lib/enum.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/enum.py b/Lib/enum.py
index b2f7b9f..a0cad06 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -436,7 +436,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):