Skip to content

gh-143811: Add helpful default error messages to AttributeError and NameError - #143813

Closed
johnslavik wants to merge 3 commits into
python:mainfrom
johnslavik:add-default-messages-attributeerror-nameerror
Closed

gh-143811: Add helpful default error messages to AttributeError and NameError#143813
johnslavik wants to merge 3 commits into
python:mainfrom
johnslavik:add-default-messages-attributeerror-nameerror

Conversation

@johnslavik

@johnslavikjohnslavik commented Jan 13, 2026

Copy link
Copy Markdown
Member

@johnslavik
johnslavik marked this pull request as ready for review January 13, 2026 19:18
Comment threadLib/traceback.py
Comment on lines 1140 to 1141
wrong_name = getattr(exc_value, "name", None)
if wrong_name is not None and wrong_name in sys.stdlib_module_names:

@johnslavikjohnslavikJan 13, 2026

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Out of scope, within the same function: wrong_name = ... and wrong_name is not None and could be removed here.

@johnslavikjohnslavikJan 19, 2026

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

@serhiy-storchaka, what do you think? Would it be of benefit to change it in this PR?
I've already made one unrelated change to reduce redundancy (although necessary to keep things simple).

Comment threadLib/traceback.py
Comment threadLib/traceback.py Outdated
Co-authored-by: Aaron Wieczorek <aaronw@fastmail.com>
@johnslavik

Copy link
Copy Markdown
MemberAuthor

I'm not confident in this change, but I'll revisit the original issue.

@johnslavik
johnslavik deleted the add-default-messages-attributeerror-nameerror branch April 20, 2026 23:18
Sign up for freeto 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.

2 participants

@johnslavik@a12k