Skip to content

gh-159190: IDLE: Show full syntax error diagnostics in Shell - #159189

Closed
NaNIsaac wants to merge 3 commits into
python:mainfrom
NaNIsaac:idle-syntaxerror-shell-main
Closed

NaNIsaac wants to merge 3 commits into
python:mainfrom
NaNIsaac:idle-syntaxerror-shell-main

Conversation

@NaNIsaac

@NaNIsaac NaNIsaac commented Oct 11, 2026 •

Copy link
Copy Markdown

Summary

Display full syntax error diagnostics in the IDLE Shell instead of showing a short error message in a modal dialog.

Motivation

One of IDLE's strengths is its simplicity. It is lightweight, included with Python, and convenient for quick experiments and learning.

However, when a syntax error occurs, IDLE currently displays only a short message in a modal dialog. Useful diagnostic information already provided by Python—such as the filename, line number, offending source code, and error position—is not shown.

This makes syntax errors unnecessarily difficult to diagnose, particularly for beginners who may not yet know how to locate the source of an error.

Displaying standard Python syntax error diagnostics also has an educational benefit. It helps beginners become familiar with the error messages they will encounter in terminals and other development environments.

The goal is to preserve IDLE's simplicity while making its error reporting more informative and useful.

Changes

  • Display complete SyntaxError diagnostics in the IDLE Shell using traceback.format_exception_only().
  • Replace modal dialogs with Shell output for syntax errors.
  • Bring the Shell window to the foreground and give it keyboard focus.
  • Preserve syntax error highlighting in the editor.
  • Preserve existing exception handling for non-syntax errors.
  • Add a regression test covering diagnostic output, editor highlighting, and Shell activation.

Testing

Tested against the current CPython main branch on Windows.

  • Windows x64 Release build — passed (0 warnings, 0 errors).
  • python -m test test_idle — passed (332 tests run, 87 skipped).
  • python -m unittest idlelib.idle_test.test_runscript.ScriptBindingTest.test_checksyntax_reports_error_in_shell -v — passed.
  • git diff --check — passed.

Related issue

Related to #91312, which discusses making better use of extended syntax error location information in IDLE.

This PR addresses a complementary aspect: where and how syntax error diagnostics are presented to users.

@NaNIsaac
NaNIsaac requested a review from terryjreedy as a code owner October 11, 2026 18:01
@python-cla-bot

python-cla-bot Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

bedevere-app Bot commented Oct 11, 2026

Copy link
Copy Markdown

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.

@NaNIsaac NaNIsaac changed the title IDLE: Show full syntax error diagnostics in Shell gh-159190: IDLE: Show full syntax error diagnostics in Shell Oct 11, 2026
@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Oct 11, 2026
@terryjreedy

Copy link
Copy Markdown
Member

Please do not randomly update to main, when not updating PR code, as it is nearly always a waste of CI resources. Closing along with the issue.

@NaNIsaac

Copy link
Copy Markdown
Author

Thank you for the clarification.

I clicked GitHub's "Update branch" button because it indicated that my branch was out of date. I wasn't aware that doing so without code changes would trigger unnecessary CI runs. I'll be more mindful of this in future contributions.

I also understand your reasoning for keeping editor syntax errors in the editor rather than displaying them in the Shell.

Thanks for taking the time to explain.

@NaNIsaac
NaNIsaac deleted the idle-syntaxerror-shell-main branch October 18, 2026 03:56
@terryjreedy

Copy link
Copy Markdown
Member

For python/cpython, with multiple merges per day, it is a crying-wolf situation. Every PR becomes 'out-of-date' in a few hours. Perhaps the devguide should explain this. And mention to not continually update. The real concern is when another merge makes a PR unmergeable due to conflict.

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

Labels

awaiting review type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants