mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
487f55d580
commit
59c27fa5cb
3 changed files with 28 additions and 8 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue