diff options
author | Ethan Furman <ethan@stoneleaf.us> | 2023-04-13 15:31:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-13 15:31:03 (GMT) |
commit | a6f95941a3d686707fb38e0f37758e666f25e180 (patch) | |
tree | 0ea29dae5df68a1d67ec01e648659c79f9ff15e6 /Lib/enum.py | |
parent | 2194071540313e2bbdc7214d77453b9ce3034a5c (diff) | |
download | cpython-a6f95941a3d686707fb38e0f37758e666f25e180.zip cpython-a6f95941a3d686707fb38e0f37758e666f25e180.tar.gz cpython-a6f95941a3d686707fb38e0f37758e666f25e180.tar.bz2 |
gh-103479: [Enum] require __new__ to be considered a data type (GH-103495)
a mixin must either have a __new__ method, or be a dataclass, to be interpreted as a data-type
Diffstat (limited to 'Lib/enum.py')
-rw-r--r-- | Lib/enum.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/enum.py b/Lib/enum.py index 432d745..e9f224a 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -967,6 +967,7 @@ class EnumType(type): @classmethod def _find_data_type_(mcls, class_name, bases): + # a datatype has a __new__ method, or a __dataclass_fields__ attribute data_types = set() base_chain = set() for chain in bases: @@ -979,7 +980,7 @@ class EnumType(type): if base._member_type_ is not object: data_types.add(base._member_type_) break - elif '__new__' in base.__dict__ or '__init__' in base.__dict__: + elif '__new__' in base.__dict__ or '__dataclass_fields__' in base.__dict__: data_types.add(candidate or base) break else: |