-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-129605: Fix crashing pyrepl when NameError occurres in __getattr__ method #129615
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
base: main
Are you sure you want to change the base?
Conversation
Misc/NEWS.d/next/Library/2025-02-03-16-39-35.gh-issue-129605.sN_0uq.rst
Outdated
Show resolved
Hide resolved
Lib/traceback.py
Outdated
@@ -1520,8 +1520,9 @@ def _compute_suggestion_error(exc_value, tb, wrong_name): | |||
# has the wrong name as attribute | |||
if 'self' in frame.f_locals: | |||
self = frame.f_locals['self'] | |||
if hasattr(self, wrong_name): | |||
return f"self.{wrong_name}" | |||
if frame.f_code.co_name != '__getattr__': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also happens with __getattribute__
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed 05a9858
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
But see the issue thread, maybe there should be a better way.
__getattr__
raising #129605