GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-132385: Fix instance error suggestions potential exceptions in `traceback` by sobolevn · Pull Request #132387 · python/cpython

Conversation

@sobolevn

@sobolevn sobolevn commented Apr 11, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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

  • Issue: Instance attr error suggestions can execute __getattr__ #132385

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sobolevn
pythongh-132385: Fix instance error suggestions side effects in `trac…
f1fc9f3
…eback`
@sobolevn
sobolevn requested review from iritkatriel and pablogsal April 11, 2025 09:44
@bedevere-app bedevere-app Bot added the awaiting core review label Apr 11, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Apr 11, 2025
Instance attr error suggestions can execute __getattr__ #132385
Closed
iritkatriel
iritkatriel reviewed Apr 11, 2025
View reviewed changes
Comment thread Lib/traceback.py Outdated
if hasattr(self, wrong_name):
try:
has_wrong_name = hasattr(self, wrong_name)
except BaseException:

@iritkatriel iritkatriel Apr 11, 2025

Copy link
Copy Markdown
Member

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 can swallow things like KeyboardInterrupt and MemoryError. We shouldn't do that.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@sobolevn sobolevn Apr 11, 2025

Copy link
Copy Markdown
Member Author

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.

Then Exception only?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pablogsal pablogsal Apr 11, 2025

Copy link
Copy Markdown
Member

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.

Would that catch SystemExit?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@sobolevn sobolevn Apr 11, 2025

Copy link
Copy Markdown
Member Author

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.

No :)

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sobolevn
Address review
06a97b7
@sobolevn

sobolevn commented Apr 11, 2025

Copy link
Copy Markdown
Member Author

After this change:

2025-04-11.13.45.38.mov
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sobolevn
sobolevn requested a review from iritkatriel May 1, 2025 18:02
iritkatriel
iritkatriel reviewed May 1, 2025
View reviewed changes
Comment thread Lib/traceback.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

iritkatriel
iritkatriel approved these changes May 2, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels May 2, 2025
@sobolevn sobolevn added the needs backport to 3.13 only security fixes label May 2, 2025
@sobolevn

sobolevn commented May 2, 2025

Copy link
Copy Markdown
Member Author

@iritkatriel thank you!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sobolevn
sobolevn merged commit 641253c into python:main May 2, 2025
@miss-islington-app

miss-islington-app Bot commented May 2, 2025

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label May 2, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 2, 2025
@sobolevn @miss-islington
pythongh-132385: Fix instance error suggestions trigger potential exc…
3c96eaf
…eptions in `traceback` (pythonGH-132387)

(cherry picked from commit 641253c)

Co-authored-by: sobolevn <[email protected]>
@bedevere-app

bedevere-app Bot commented May 2, 2025

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label May 2, 2025
sobolevn added a commit that referenced this pull request May 2, 2025
@miss-islington @sobolevn
[3.13] gh-132385: Fix instance error suggestions trigger potential ex…
16e9e74
…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 <[email protected]>
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
@sobolevn @Pranjal095
pythongh-132385: Fix instance error suggestions trigger potential exc…
88f00e3
…eptions in `traceback` (python#132387)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iritkatriel iritkatriel iritkatriel approved these changes
@pablogsal pablogsal Awaiting requested review from pablogsal

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@sobolevn @iritkatriel @pablogsal
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.