mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-103056: [Enum] ensure final _generate_next_value_ is a staticmethod (GH-103062)
This commit is contained in:
parent
56d055a0d8
commit
b838d80085
3 changed files with 23 additions and 0 deletions
|
@ -518,8 +518,13 @@ class EnumType(type):
|
|||
#
|
||||
# adjust the sunders
|
||||
_order_ = classdict.pop('_order_', None)
|
||||
_gnv = classdict.get('_generate_next_value_')
|
||||
if _gnv is not None and type(_gnv) is not staticmethod:
|
||||
_gnv = staticmethod(_gnv)
|
||||
# convert to normal dict
|
||||
classdict = dict(classdict.items())
|
||||
if _gnv is not None:
|
||||
classdict['_generate_next_value_'] = _gnv
|
||||
#
|
||||
# data type of member and the controlling Enum class
|
||||
member_type, first_enum = metacls._get_mixins_(cls, bases)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue