Skip to content

Commit b8d1623

Browse files
gh-103272: regression test for getattr exception in property (GH-103336)
(cherry picked from commit 5d7d86f) Co-authored-by: sunmy2019 <[email protected]>
1 parent 1b1f016 commit b8d1623

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Lib/test/test_descr.py

+13
Original file line numberDiff line numberDiff line change
@@ -4999,6 +4999,19 @@ class Child(Parent):
49994999
gc.collect()
50005000
self.assertEqual(Parent.__subclasses__(), [])
50015001

5002+
def test_attr_raise_through_property(self):
5003+
# add test case for gh-103272
5004+
class A:
5005+
def __getattr__(self, name):
5006+
raise ValueError("FOO")
5007+
5008+
@property
5009+
def foo(self):
5010+
return self.__getattr__("asdf")
5011+
5012+
with self.assertRaisesRegex(ValueError, "FOO"):
5013+
A().foo
5014+
50025015

50035016
class DictProxyTests(unittest.TestCase):
50045017
def setUp(self):

0 commit comments

Comments
 (0)