summaryrefslogtreecommitdiffstats
path: root/Lib/enum.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-12-08 07:21:29 (GMT)
committerGitHub <noreply@github.com>2022-12-08 07:21:29 (GMT)
commitd4426c829565e3ef922c091ee9bd48bc556f2550 (patch)
treedb55eedff5f38c254f7a6caedb3de829ae1d0971 /Lib/enum.py
parent846898e5ab0fb1bf740263573f01669be186645f (diff)
downloadcpython-d4426c829565e3ef922c091ee9bd48bc556f2550.zip
cpython-d4426c829565e3ef922c091ee9bd48bc556f2550.tar.gz
cpython-d4426c829565e3ef922c091ee9bd48bc556f2550.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. (cherry picked from commit ded02ca54d7bfa32c8eab0871d56e4547cd356eb) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
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 1efddfa..7ad599b 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -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):