[Python-checkins] gh-103272: regression test for getattr exception in property (#103336)
hauntsaninja
webhook-mailer at python.org
Fri Apr 7 15:11:18 EDT 2023
https://github.com/python/cpython/commit/5d7d86f2fdbbfc23325e7256ee289bf20ce7124e
commit: 5d7d86f2fdbbfc23325e7256ee289bf20ce7124e
branch: main
author: sunmy2019 <59365878+sunmy2019 at users.noreply.github.com>
committer: hauntsaninja <12621235+hauntsaninja at users.noreply.github.com>
date: 2023-04-07T12:11:11-07:00
summary:
gh-103272: regression test for getattr exception in property (#103336)
files:
M Lib/test/test_descr.py
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index cbc020d1d390..f17bb1813b9d 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -5003,6 +5003,19 @@ class Child(Parent):
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):
More information about the Python-checkins
mailing list