Skip to content

gh-135511 Fixed NameError and AttributeError lack of the message in IDLE #135526

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 9 commits into
base: main
Choose a base branch
from

Conversation

Locked-chess-official
Copy link

@Locked-chess-official Locked-chess-official commented Jun 15, 2025

@python-cla-bot
Copy link

python-cla-bot bot commented Jun 15, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Jun 15, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@Locked-chess-official Locked-chess-official changed the title Fixed NameError and AttributeError lack of the message in IDLE gh-135511 Fixed NameError and AttributeError lack of the message in IDLE Jun 15, 2025
@Locked-chess-official
Copy link
Author

I use blurb to create a .rst file then click add file and choose it to IDLE, but it was wrong. So how should I do?

Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

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

To add a test, I think if might be sufficient to add the following tuple to the end of data in test_idle.test_run.ExceptionTest.

            ('raise NameError("123\n456")', NameError, "123\n456\n"),

If you want me to make changes and test, I will, but I need sleep now.

@bedevere-app
Copy link

bedevere-app bot commented Jun 15, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@terryjreedy
Copy link
Member

The hint process is rather fragile. Modifying get_message_lines so that sys.excepthook does not print any traceback, which require setting err.traceback to None before the call in addition to not passing a traceback, can alter the hint. In particular, for abc, "Did you mean: 'abs'?" is omitted and only "Did you forget to import 'abc'?" is added. Not only do the message changes break multiple tests, but this particular result is worse for the user. I am accepting the alternative of directly printing multiline user name error messages instead of calling a modified get_message_lines. I will look at adding a new test_xxx function to test the case fixed here.

@Locked-chess-official
Copy link
Author

I have made the requested changes; please review again

@bedevere-app
Copy link

bedevere-app bot commented Jun 16, 2025

Thanks for making the requested changes!

@terryjreedy: please review the changes made to this pull request.

@bedevere-app bedevere-app bot requested a review from terryjreedy June 16, 2025 01:03
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.

2 participants