Skip to content

gh-132385: Fix instance error suggestions potential exceptions in traceback #132387

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 2 commits into from
May 2, 2025

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Apr 11, 2025

It does not cover all side-effects, it will still evaluate print, etc.
But, it does not fail with exceptions at least.

Lib/traceback.py Outdated
if hasattr(self, wrong_name):
try:
has_wrong_name = hasattr(self, wrong_name)
except BaseException:
Copy link
Member

Choose a reason for hiding this comment

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

This can swallow things like KeyboardInterrupt and MemoryError. We shouldn't do that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Then Exception only?

Copy link
Member

Choose a reason for hiding this comment

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

Would that catch SystemExit?

Copy link
Member Author

Choose a reason for hiding this comment

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

No :)

>>> SystemExit.__mro__
(<class 'SystemExit'>, <class 'BaseException'>, <class 'object'>)

@sobolevn
Copy link
Member Author

After this change:

2025-04-11.13.45.38.mov

@sobolevn sobolevn requested a review from iritkatriel May 1, 2025 18:02
@sobolevn sobolevn added the needs backport to 3.13 bugs and security fixes label May 2, 2025
@sobolevn
Copy link
Member Author

sobolevn commented May 2, 2025

@iritkatriel thank you!

@sobolevn sobolevn merged commit 641253c into python:main May 2, 2025
45 checks passed
@miss-islington-app
Copy link

Thanks @sobolevn for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 2, 2025
…eptions in `traceback` (pythonGH-132387)

(cherry picked from commit 641253c)

Co-authored-by: sobolevn <mail@sobolevn.me>
@bedevere-app
Copy link

bedevere-app bot commented May 2, 2025

GH-133297 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label May 2, 2025
sobolevn added a commit that referenced this pull request May 2, 2025
…ceptions in `traceback` (GH-132387) (#133297)

gh-132385: Fix instance error suggestions trigger potential exceptions in `traceback` (GH-132387)
(cherry picked from commit 641253c)

Co-authored-by: sobolevn <mail@sobolevn.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants