summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-04-11 10:53:06 (GMT)
committerGitHub <noreply@github.com>2023-04-11 10:53:06 (GMT)
commit55c99d97e14618dfce41472dd4446f763b0da13f (patch)
tree457a036aa57a59204105937c6cba43f3ce6ba288 /Lib
parente071f00aaefae9eccf787d5c50396c26c8616483 (diff)
downloadcpython-55c99d97e14618dfce41472dd4446f763b0da13f.zip
cpython-55c99d97e14618dfce41472dd4446f763b0da13f.tar.gz
cpython-55c99d97e14618dfce41472dd4446f763b0da13f.tar.bz2
gh-77757: replace exception wrapping by PEP-678 notes in typeobject's __set_name__ (#103402)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_functools.py4
-rw-r--r--Lib/test/test_subclassinit.py22
2 files changed, 12 insertions, 14 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index 57db96d..af28605 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -2980,7 +2980,7 @@ class TestCachedProperty(unittest.TestCase):
def test_reuse_different_names(self):
"""Disallow this case because decorated function a would not be cached."""
- with self.assertRaises(RuntimeError) as ctx:
+ with self.assertRaises(TypeError) as ctx:
class ReusedCachedProperty:
@py_functools.cached_property
def a(self):
@@ -2989,7 +2989,7 @@ class TestCachedProperty(unittest.TestCase):
b = a
self.assertEqual(
- str(ctx.exception.__context__),
+ str(ctx.exception),
str(TypeError("Cannot assign the same cached_property to two different names ('a' and 'b')."))
)
diff --git a/Lib/test/test_subclassinit.py b/Lib/test/test_subclassinit.py
index 0ad7d17..310473a 100644
--- a/Lib/test/test_subclassinit.py
+++ b/Lib/test/test_subclassinit.py
@@ -134,30 +134,28 @@ class Test(unittest.TestCase):
def __set_name__(self, owner, name):
1/0
- with self.assertRaises(RuntimeError) as cm:
+ with self.assertRaises(ZeroDivisionError) as cm:
class NotGoingToWork:
attr = Descriptor()
- exc = cm.exception
- self.assertRegex(str(exc), r'\bNotGoingToWork\b')
- self.assertRegex(str(exc), r'\battr\b')
- self.assertRegex(str(exc), r'\bDescriptor\b')
- self.assertIsInstance(exc.__cause__, ZeroDivisionError)
+ notes = cm.exception.__notes__
+ self.assertRegex(str(notes), r'\bNotGoingToWork\b')
+ self.assertRegex(str(notes), r'\battr\b')
+ self.assertRegex(str(notes), r'\bDescriptor\b')
def test_set_name_wrong(self):
class Descriptor:
def __set_name__(self):
pass
- with self.assertRaises(RuntimeError) as cm:
+ with self.assertRaises(TypeError) as cm:
class NotGoingToWork:
attr = Descriptor()
- exc = cm.exception
- self.assertRegex(str(exc), r'\bNotGoingToWork\b')
- self.assertRegex(str(exc), r'\battr\b')
- self.assertRegex(str(exc), r'\bDescriptor\b')
- self.assertIsInstance(exc.__cause__, TypeError)
+ notes = cm.exception.__notes__
+ self.assertRegex(str(notes), r'\bNotGoingToWork\b')
+ self.assertRegex(str(notes), r'\battr\b')
+ self.assertRegex(str(notes), r'\bDescriptor\b')
def test_set_name_lookup(self):
resolved = []