[Python-checkins] bpo-46269: [Enum] remove special-casing of `__new__` in `EnumType.__dir__` (GH-30421)

ethanfurman webhook-mailer at python.org
Wed Jan 5 12:06:08 EST 2022


https://github.com/python/cpython/commit/817a6bc9f7b802511c4d42273a621c556a48870b
commit: 817a6bc9f7b802511c4d42273a621c556a48870b
branch: main
author: Nikita Sobolev <mail at sobolevn.me>
committer: ethanfurman <ethan at stoneleaf.us>
date: 2022-01-05T09:06:02-08:00
summary:

bpo-46269: [Enum] remove special-casing of `__new__` in `EnumType.__dir__` (GH-30421)

files:
A Misc/NEWS.d/next/Library/2022-01-05-18-16-13.bpo-46269.K16Z1S.rst
M Lib/enum.py

diff --git a/Lib/enum.py b/Lib/enum.py
index 8efc38c3d78db..86928b4f79f0b 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -652,10 +652,6 @@ def __dir__(self):
         # if and only if they have been user-overridden
         enum_dunders = set(filter(_is_dunder, enum_dict))
 
-        # special-case __new__
-        if self.__new__ is not first_enum_base.__new__:
-            add_to_dir('__new__')
-
         for cls in mro:
             # Ignore any classes defined in this module
             if cls is object or is_from_this_module(cls):
diff --git a/Misc/NEWS.d/next/Library/2022-01-05-18-16-13.bpo-46269.K16Z1S.rst b/Misc/NEWS.d/next/Library/2022-01-05-18-16-13.bpo-46269.K16Z1S.rst
new file mode 100644
index 0000000000000..5d3687aaddfea
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-01-05-18-16-13.bpo-46269.K16Z1S.rst
@@ -0,0 +1 @@
+Remove special-casing of ``__new__`` in :meth:`enum.Enum.__dir__`.



More information about the Python-checkins mailing list