8000 gh-96663: Add a better error message for __dict__-less classes setattr by Gobot1234 · Pull Request #103232 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-96663: Add a better error message for __dict__-less classes setattr #103232

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 11 commits into from
Jul 22, 2023
Prev Previous commit
Next Next commit
Remove test for suggestions
  • Loading branch information
Gobot1234 authored Apr 4, 2023
commit edc27972c67faeeaeed17bf8ed9f0bc950199256
10 changes: 1 addition & 9 deletions Lib/test/test_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ class A:
pass
class B:
y = 0
__slots__ = ('z', 'foo')
__slots__ = ('z',)

error_msg = "'A' object has no attribute 'x'"
with self.assertRaisesRegex(AttributeError, error_msg):
Expand All @@ -659,14 +659,6 @@ class B:
):
B().x = 0

with self.assertRaisesRegex(
AttributeError,
"'B' object has no attribute 'fod' and no "
r"__dict__ for setting new attributes. Did you mean: 'foo'\?"
""
):
B().fod = 1

error_msg = "'B' object attribute 'y' is read-only"
with self.assertRaisesRegex(AttributeError, error_msg):
del B().y
Expand Down
0