summaryrefslogtreecommitdiffstats
path: root/Lib/enum.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-10-31 22:01:28 (GMT)
committerGitHub <noreply@github.com>2023-10-31 22:01:28 (GMT)
commitec00397912ea57a896cb7029e14fad89371b8b2f (patch)
tree2f0efa07d2acab3f0abb328cbd8fc67cfa91933c /Lib/enum.py
parent4f619e83fe1416c9b8d618533a0aaec0b4443b11 (diff)
downloadcpython-ec00397912ea57a896cb7029e14fad89371b8b2f.zip
cpython-ec00397912ea57a896cb7029e14fad89371b8b2f.tar.gz
cpython-ec00397912ea57a896cb7029e14fad89371b8b2f.tar.bz2
[3.12] gh-111181: Fix enum doctests (GH-111180) (GH-111518)
gh-111181: Fix enum doctests (GH-111180) (cherry picked from commit c4dc5a6ae8aa13abb743182df088f1a3526d1bcd) Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Diffstat (limited to 'Lib/enum.py')
-rw-r--r--Lib/enum.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/Lib/enum.py b/Lib/enum.py
index c207dc2..4bd3756 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -1217,14 +1217,13 @@ class Enum(metaclass=EnumType):
def __dir__(self):
"""
- Returns all members and all public methods
+ Returns public methods and other interesting attributes.
"""
- if self.__class__._member_type_ is object:
- interesting = set(['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'value'])
- else:
+ interesting = set()
+ if self.__class__._member_type_ is not object:
interesting = set(object.__dir__(self))
for name in getattr(self, '__dict__', []):
- if name[0] != '_':
+ if name[0] != '_' and name not in self._member_map_:
interesting.add(name)
for cls in self.__class__.mro():
for name, obj in cls.__dict__.items():
@@ -1237,7 +1236,7 @@ class Enum(metaclass=EnumType):
else:
# in case it was added by `dir(self)`
interesting.discard(name)
- else:
+ elif name not in self._member_map_:
interesting.add(name)
names = sorted(
set(['__class__', '__doc__', '__eq__', '__hash__', '__module__'])