Skip to content

gh-105689: Parse only the current statement in the IDLE Shell - #157594

Merged
terryjreedy merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-105689-shell-hyperparser
Sep 17, 2026
Merged

terryjreedy merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-105689-shell-hyperparser

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

A bug in the conversion of a Shell indents from a literal tab to (default) 4 spaces (PR #25678, issue #82073) resulted in
HyperParser and newline_and_indent_event taking the editor path in the Shell and scanning back through previous output. Unbalanced quotes or parentheses in that output — a traceback for raise ValueError("""\n"""), a SyntaxError: '(' was never closed — then broke calltips, parenthesis matching and auto-indent for everything typed afterwards. Use an explicit is_shell attribute and parse only the current statement in the Shell, as before 3.10. This also fixes the Shell examples of #124451.

🤖 Generated with Claude Code

Since the prompts moved to the sidebar, sys.ps1 ends with a newline
and prompt_last_line is empty, so HyperParser and newline_and_indent
took the editor path in the Shell and parsed previous output. Use an
explicit is_shell attribute instead.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Sep 15, 2026
@terryjreedy

Copy link
Copy Markdown
Member

The space indent patch was developed in parallel with and partially as an alternative to Tal Einat's proposed sidebar (issue #82084). The original intent of my patch was to move the default prompt '>>>\n', possibly replaced by sys.ps1, to it own line so as to enable the indent change. When the two patches worked so well together, we dropped the idea of adding an option for an own-line prompt instead of the sidebar. That idea is why the self.ps1 and self.prompt lines remain around the line removed. They can go in a separate cleanup patch as I am ready to merge this. I wish I had added a clear 'I am Shell' variable in my patch.

@terryjreedy
terryjreedy merged commit b42dcf6 into python:main Sep 17, 2026
59 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Sep 17, 2026

Copy link
Copy Markdown

GH-157650 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 17, 2026
@bedevere-app

bedevere-app Bot commented Sep 17, 2026

Copy link
Copy Markdown

GH-157651 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 17, 2026
@bedevere-app

bedevere-app Bot commented Sep 17, 2026

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Sep 17, 2026
terryjreedy pushed a commit that referenced this pull request Sep 17, 2026
…H-157594) (#157652)

gh-105689: Parse only the current statement in the IDLE Shell (GH-157594)

Since the prompts moved to the sidebar, sys.ps1 ends with a newline
and prompt_last_line is empty, so HyperParser and newline_and_indent
took the editor path in the Shell and parsed previous output. Use an
explicit is_shell attribute instead.
(cherry picked from commit b42dcf6)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
terryjreedy pushed a commit that referenced this pull request Sep 17, 2026
…H-157594) (#157651)

gh-105689: Parse only the current statement in the IDLE Shell (GH-157594)

Since the prompts moved to the sidebar, sys.ps1 ends with a newline
and prompt_last_line is empty, so HyperParser and newline_and_indent
took the editor path in the Shell and parsed previous output. Use an
explicit is_shell attribute instead.
(cherry picked from commit b42dcf6)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@python python deleted a comment from bedevere-bot Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants