]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-103272: regression test for getattr exception in property (#103336)
authorsunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Fri, 7 Apr 2023 19:11:11 +0000 (03:11 +0800)
committerGitHub <noreply@github.com>
Fri, 7 Apr 2023 19:11:11 +0000 (12:11 -0700)
Lib/test/test_descr.py

index cbc020d1d3904aa8b75f2ba3603fd1700989fc97..f17bb1813b9d87c3847b98cf93afb39cbed8b12b 100644 (file)
@@ -5003,6 +5003,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):