From ded02ca54d7bfa32c8eab0871d56e4547cd356eb Mon Sep 17 00:00:00 2001 From: Ethan Furman Date: Wed, 7 Dec 2022 22:58:08 -0800 Subject: 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. --- Lib/enum.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Lib/enum.py') diff --git a/Lib/enum.py b/Lib/enum.py index b2f7b9f8d4..a0cad066dc 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): -- cgit v1.2.1