gh-102213: Optimize the performance of __getattr__ (GH-103761)

Co-authored-by: Kirill <80244920+Eclips4@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Xiang Wang <34048878+wangxiang-hz@users.noreply.github.com>
This commit is contained in:
sunmy2019 2023-05-01 18:10:35 +08:00 committed by GitHub
parent 487f55d580
commit 59c27fa5cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 8 deletions

View file

@ -5004,7 +5004,7 @@ order (MRO) for bases """
self.assertEqual(Parent.__subclasses__(), [])
def test_attr_raise_through_property(self):
# add test case for gh-103272
# test case for gh-103272
class A:
def __getattr__(self, name):
raise ValueError("FOO")
@ -5016,6 +5016,19 @@ order (MRO) for bases """
with self.assertRaisesRegex(ValueError, "FOO"):
A().foo
# test case for gh-103551
class B:
@property
def __getattr__(self, name):
raise ValueError("FOO")
@property
def foo(self):
raise NotImplementedError("BAR")
with self.assertRaisesRegex(NotImplementedError, "BAR"):
B().foo
class DictProxyTests(unittest.TestCase):
def setUp(self):