Skip to content

Commit be84daf

Browse files
authored
Revert "gh-93910: [Enum] restore member.member restriction while keeping performance boost (GH-94913)" (#94981)
This reverts commit 30f28ac.
1 parent eda2f90 commit be84daf

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
@@ -1125,14 +1125,6 @@ def __new__(cls, value):
11251125
def __init__(self, *args, **kwds):
11261126
pass
11271127

1128-
def __getattribute__(self, name):
1129-
self_dict = super().__getattribute__('__dict__')
1130-
cls = super().__getattribute__('__class__')
1131-
value = super().__getattribute__(name)
1132-
if isinstance(value, cls) and name not in self_dict and name in self._member_names_:
1133-
raise AttributeError("<enum '%s'> member has no attribute %r" % (cls.__name__, name))
1134-
return super().__getattribute__(name)
1135-
11361128
def _generate_next_value_(name, start, count, last_values):
11371129
"""
11381130
Generate the next value when not given.

Diff for: Lib/test/test_enum.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -2611,19 +2611,14 @@ class Private(Enum):
26112611
self.assertEqual(Private._Private__corporal, 'Radar')
26122612
self.assertEqual(Private._Private__major_, 'Hoolihan')
26132613

2614+
@unittest.skip("Accessing all values retained for performance reasons, see GH-93910")
26142615
def test_exception_for_member_from_member_access(self):
26152616
with self.assertRaisesRegex(AttributeError, "<enum .Di.> member has no attribute .NO."):
26162617
class Di(Enum):
26172618
YES = 1
26182619
NO = 0
26192620
nope = Di.YES.NO
26202621

2621-
def test_no_exception_for_overridden_member_from_member_access(self):
2622-
class Di(Enum):
2623-
YES = 1
2624-
NO = 0
2625-
Di.YES.NO = Di.NO
2626-
nope = Di.YES.NO
26272622

26282623
def test_dynamic_members_with_static_methods(self):
26292624
#

0 commit comments

Comments
 (0)