[Python-checkins] bpo-42727: [Enum] use super() and include **kwds (GH-23927)

miss-islington webhook-mailer at python.org
Fri Dec 25 11:07:38 EST 2020


https://github.com/python/cpython/commit/fbffda25b4b5f537e651eaab4ca1ec4cde800709
commit: fbffda25b4b5f537e651eaab4ca1ec4cde800709
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2020-12-25T08:07:30-08:00
summary:

bpo-42727: [Enum] use super() and include **kwds (GH-23927)


for multiple inheritance support:

use super().new
pass **kwds to super().new
(cherry picked from commit 786d97a66cac48e7a933010367b8993a5b3ab85b)

Co-authored-by: Ethan Furman <ethan at stoneleaf.us>

files:
M Lib/enum.py

diff --git a/Lib/enum.py b/Lib/enum.py
index aa9f4b00dd74d..1c22380f03b38 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -227,10 +227,10 @@ def __new__(metacls, cls, bases, classdict, **kwds):
         # create our new Enum type
         if bases:
             bases = (_NoInitSubclass, ) + bases
-            enum_class = type.__new__(metacls, cls, bases, classdict)
+            enum_class = super().__new__(metacls, cls, bases, classdict, **kwds)
             enum_class.__bases__ = enum_class.__bases__[1:] #or (object, )
         else:
-            enum_class = type.__new__(metacls, cls, bases, classdict)
+            enum_class = super().__new__(metacls, cls, bases, classdict, **kwds)
         old_init_subclass = getattr(enum_class, '__init_subclass__', None)
         # and restore the new one (if there was one)
         if new_init_subclass is not None:



More information about the Python-checkins mailing list