summaryrefslogtreecommitdiffstats
path: root/Lib/enum.py
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2023-03-27 23:25:19 (GMT)
committerGitHub <noreply@github.com>2023-03-27 23:25:19 (GMT)
commitb838d80085b0162cc2ae7b4db5d2a9d9c6a28366 (patch)
tree65b022368e72dedddbe231fd4d28904de6f641a4 /Lib/enum.py
parent56d055a0d81a809e4ff8e1d56756a3bf32317efb (diff)
downloadcpython-b838d80085b0162cc2ae7b4db5d2a9d9c6a28366.zip
cpython-b838d80085b0162cc2ae7b4db5d2a9d9c6a28366.tar.gz
cpython-b838d80085b0162cc2ae7b4db5d2a9d9c6a28366.tar.bz2
gh-103056: [Enum] ensure final _generate_next_value_ is a staticmethod (GH-103062)
Diffstat (limited to 'Lib/enum.py')
-rw-r--r--Lib/enum.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/enum.py b/Lib/enum.py
index ba92766..2624a08 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -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)