Skip to content

IDLE doesn't know where to start parsing #124451

Description

@ujan-r

Bug report

Bug description:

After making a typo in IDLE, I noticed some unexpected calltips and incorrectly matched parentheses. These seem to be caused by the parser not knowing where the current prompt begins. I'll try to send in a PR tonight.

Examples

Parentheses are incorrectly matched:

>>> (1 2
...
SyntaxError: '(' was never closed
>>> ) # IDLE highlights this as the closing paren

Matching parentheses aren't detected (from #85560):

>>> (1 if 0
     else 0) # IDLE beeps here, not detecting the opening paren

Calltip appears unexpectedly (Python 3.12; a new error message hides this issue in the latest version):

>>> (1 2
...
SyntaxError: incomplete input
>>> ( # this opens the calltip for `input`

CPython versions tested on:

3.12, CPython main branch

Operating systems tested on:

macOS

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Sep 24, 2024
  2. terryjreedy commented on Sep 25, 2024

    @terryjreedy
    Member

    I verified examples 1 and 3 on macOS and Windows. They are specific to Shell in that only Shell gets SyntaxError messages mixed in with code to be executed. Put the same text (without the prompts*) in an IDLE code editor and the behavior is correct.

    • Prompts are now in a sidebar, not in the tkinter Text window hyperparser sees.

    The immediate fix is that hyperparser know when it is in Shell and when so, treat the code-begin mark as beginning of file. A different fix that I have already planned it to not mix SyntaxError and new prompts into the new code area. Instead intercept it and display the message in the status bar or a popup. The latter is used (currently) for editor windows, but I have thought of changing for short messages.

    I also want to replace using one Text for both history/output and code input, with a movable boundary between, and instead use different widgets for the different functions.

  3. moved this from Done to Todo in IDLE Issueson Sep 25, 2024
  4. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Nov 6, 2025
  5. removed
    stdlibStandard Library Python modules in the Lib/ directory
    on Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-IDLEtype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions