8000 gh-129605: Fix crashing pyrepl when NameError occurres in __getattr__ method by srinivasreddy · Pull Request #129615 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

srinivasreddy
Copy link
Contributor
@srinivasreddy srinivasreddy commented Feb 3, 2025

@srinivasreddy srinivasreddy marked this pull request as ready for review February 3, 2025 13:53
@srinivasreddy srinivasreddy changed the title Fix crashing pyrepl when NameError occurres in __getattr__ method gh-129605: Fix crashing pyrepl when NameError occurres in __getattr__ method Feb 3, 2025
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__':
Copy link
Member

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__.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed 05a9858

Copy link
Contributor
@skirpichev skirpichev left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0