Skip to content

Commit b03554b

Browse files
authored
Revert "gh-93910: [Enum] restore member.member restriction while keeping performance boost (GH-94913)"
This reverts commit c20186c.
1 parent fc0dc92 commit b03554b

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

Diff for: Lib/enum.py

-8
Original file line numberDiff line numberDiff line change
@@ -1112,14 +1112,6 @@ def __new__(cls, value):
11121112
def __init__(self, *args, **kwds):
11131113
pass
11141114

1115-
def __getattribute__(self, name):
1116-
self_dict = super().__getattribute__('__dict__')
1117-
cls = super().__getattribute__('__class__')
1118-
value = super().__getattribute__(name)
1119-
if isinstance(value, cls) and name not in self_dict and name in self._member_names_:
1120-
raise AttributeError("<enum '%s'> member has no attribute %r" % (cls.__name__, name))
1121-
return super().__getattribute__(name)
1122-
11231115
def _generate_next_value_(name, start, count, last_values):
11241116
"""
11251117
Generate the next value when not given.

Diff for: Lib/test/test_enum.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -2646,19 +2646,14 @@ class Private(Enum):
26462646
self.assertEqual(Private._Private__corporal, 'Radar')
26472647
self.assertEqual(Private._Private__major_, 'Hoolihan')
26482648

2649+
@unittest.skip("Accessing all values retained for performance reasons, see GH-93910")
26492650
def test_exception_for_member_from_member_access(self):
26502651
with self.assertRaisesRegex(AttributeError, "<enum .Di.> member has no attribute .NO."):
26512652
class Di(Enum):
26522653
YES = 1
26532654
NO = 0
26542655
nope = Di.YES.NO
26552656

2656-
def test_no_exception_for_overridden_member_from_member_access(self):
2657-
class Di(Enum):
2658-
YES = 1
2659-
NO = 0
2660-
Di.YES.NO = Di.NO
2661-
nope = Di.YES.NO
26622657

26632658
def test_dynamic_members_with_static_methods(self):
26642659
#

0 commit comments

Comments
 (0)