8000 Revert "Handle strange exceptions raised on attempting to access `__s… · python/cpython@fdab495 · GitHub
[go: up one dir, main page]

Skip to content

Commit fdab495

Browse files
committed
Revert "Handle strange exceptions raised on attempting to access __set_name__"
This reverts commit 1909fd5.
1 parent 9fd8b6b commit fdab495

File tree

2 files changed

+1
-17
lines changed

2 files changed

+1
-17
lines changed

Lib/test/test_typing.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7577,22 +7577,6 @@ class NamedTupleClass(NamedTuple):
75777577
normal_exception.__notes__[0].replace("NormalClass", "NamedTupleClass")
75787578
)
75797579

7580-
def test_exception_raised_if_accessing_set_name_causes_strange_error(self):
7581-
class Meta(type):
7582-
def __getattribute__(self, attr):
7583-
if attr == "__set_name__":
7584-
raise TypeError("NO")
7585-
7586-
class VeryAnnoying(metaclass=Meta): pass
7587-
7588-
# Sanity check to make sure the test is setup correctly:
7589-
with self.assertRaises(TypeError):
7590-
VeryAnnoying.__set_name__
7591-
7592-
# The real test here is just that this class creation succeeds:
7593-
class Foo(NamedTuple):
7594-
attr = VeryAnnoying()
7595-
75967580

75977581
class TypedDictTests(BaseTestCase):
75987582
def test_basics_functional_syntax(self):

Lib/typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2734,7 +2734,7 @@ def __new__(cls, typename, bases, ns):
27342734
setattr(nm_tpl, key, val)
27352735
try:
27362736
set_name = type(val).__set_name__
2737-
except Exception:
2737+
except AttributeError:
27382738
pass
27392739
else:
27402740
try:

0 commit comments

Comments
 (0)
0