mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +00:00
bpo-41889: [Enum] fix multiple-inheritance regression (GH-22487) (GH-23673)
(cherry picked from commit c266736ec1
)
This commit is contained in:
parent
60463e8e4f
commit
be52ca45d9
3 changed files with 35 additions and 3 deletions
11
Lib/enum.py
11
Lib/enum.py
|
@ -145,8 +145,9 @@ class EnumMeta(type):
|
|||
for key in ignore:
|
||||
classdict.pop(key, None)
|
||||
member_type, first_enum = metacls._get_mixins_(cls, bases)
|
||||
__new__, save_new, use_args = metacls._find_new_(classdict, member_type,
|
||||
first_enum)
|
||||
__new__, save_new, use_args = metacls._find_new_(
|
||||
classdict, member_type, first_enum,
|
||||
)
|
||||
|
||||
# save enum items into separate mapping so they don't get baked into
|
||||
# the new class
|
||||
|
@ -500,12 +501,16 @@ class EnumMeta(type):
|
|||
for base in chain.__mro__:
|
||||
if base is object:
|
||||
continue
|
||||
elif issubclass(base, Enum):
|
||||
if base._member_type_ is not object:
|
||||
data_types.append(base._member_type_)
|
||||
break
|
||||
elif '__new__' in base.__dict__:
|
||||
if issubclass(base, Enum):
|
||||
continue
|
||||
data_types.append(candidate or base)
|
||||
break
|
||||
elif not issubclass(base, Enum):
|
||||
else:
|
||||
candidate = base
|
||||
if len(data_types) > 1:
|
||||
raise TypeError('%r: too many data types: %r' % (class_name, data_types))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue