Skip to content

gh-102213: Optimize the performance of __getattr__ #103761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 1, 2023
Prev Previous commit
Next Next commit
add test case for gh-103551
  • Loading branch information
sunmy2019 committed Apr 25, 2023
commit c3aebf655b19ced83e58e6376d783e7a11e60ffc
15 changes: 14 additions & 1 deletion Lib/test/test_descr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5004,7 +5004,7 @@ class Child(Parent):
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")
Expand All @@ -5016,6 +5016,19 @@ def foo(self):
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):
Expand Down