]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-103272: regression test for getattr exception in property (GH-103336)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 7 Apr 2023 19:36:10 +0000 (12:36 -0700)
committerGitHub <noreply@github.com>
Fri, 7 Apr 2023 19:36:10 +0000 (12:36 -0700)
(cherry picked from commit 5d7d86f2fdbbfc23325e7256ee289bf20ce7124e)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Lib/test/test_descr.py

index 3145dff81b4d89b7867524d5afa4c764319eab92..f07d7d4596599c76c98e6d8e3fdaeca45a2461b6 100644 (file)
@@ -4999,6 +4999,19 @@ order (MRO) for bases """
         gc.collect()
         self.assertEqual(Parent.__subclasses__(), [])
 
+    def test_attr_raise_through_property(self):
+        # add test case for gh-103272
+        class A:
+            def __getattr__(self, name):
+                raise ValueError("FOO")
+
+            @property
+            def foo(self):
+                return self.__getattr__("asdf")
+
+        with self.assertRaisesRegex(ValueError, "FOO"):
+            A().foo
+
 
 class DictProxyTests(unittest.TestCase):
     def setUp(self):