From 630d2e14c5e232f5c86fc1b8a7d61b6df081a352 Mon Sep 17 00:00:00 2001 From: Ethan Furman Date: Thu, 24 Dec 2020 10:05:17 -0800 Subject: [PATCH] Revert "[Enum] EnumMeta.__prepare__ now accepts **kwds (#23917)" This reverts commit 6ec0adefad60ec7cdec61c44baecf1dccc1461ab. --- Lib/enum.py | 2 +- Lib/test/test_enum.py | 12 +----------- .../Library/2020-12-23-19-43-06.bpo-42727.WH3ODh.rst | 2 -- 3 files changed, 2 insertions(+), 14 deletions(-) delete mode 100644 Misc/NEWS.d/next/Library/2020-12-23-19-43-06.bpo-42727.WH3ODh.rst diff --git a/Lib/enum.py b/Lib/enum.py index 36a9a400a11..0070ebe1363 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -178,7 +178,7 @@ class EnumMeta(type): Metaclass for Enum """ @classmethod - def __prepare__(metacls, cls, bases, **kwds): + def __prepare__(metacls, cls, bases): # check that previous enum members do not exist metacls._check_for_existing_members(cls, bases) # create the namespace dict diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py index 19b4fa5464c..a83241cbb57 100644 --- a/Lib/test/test_enum.py +++ b/Lib/test/test_enum.py @@ -2119,7 +2119,7 @@ class TestEnum(unittest.TestCase): one = '1' two = b'2', 'ascii', 9 - def test_init_subclass_calling(self): + def test_init_subclass(self): class MyEnum(Enum): def __init_subclass__(cls, **kwds): super(MyEnum, cls).__init_subclass__(**kwds) @@ -2155,16 +2155,6 @@ class TestEnum(unittest.TestCase): self.assertFalse(NeverEnum.__dict__.get('_test1', False)) self.assertFalse(NeverEnum.__dict__.get('_test2', False)) - def test_init_subclass_parameter(self): - class multiEnum(Enum): - def __init_subclass__(cls, multi): - for member in cls: - member._as_parameter_ = multi * member.value - class E(multiEnum, multi=3): - A = 1 - B = 2 - self.assertEqual(E.A._as_parameter_, 3) - self.assertEqual(E.B._as_parameter_, 6) @unittest.skipUnless( sys.version_info[:2] == (3, 9), diff --git a/Misc/NEWS.d/next/Library/2020-12-23-19-43-06.bpo-42727.WH3ODh.rst b/Misc/NEWS.d/next/Library/2020-12-23-19-43-06.bpo-42727.WH3ODh.rst deleted file mode 100644 index a986cb960a7..00000000000 --- a/Misc/NEWS.d/next/Library/2020-12-23-19-43-06.bpo-42727.WH3ODh.rst +++ /dev/null @@ -1,2 +0,0 @@ -`EnumMeta.__prepare__` now accepts `**kwds` to properly support -`__init_subclass__`