Skip to content

gh-93016: Fix parsing of arguments in the IDLE "Run... Customized" dialog - #157635

Merged
terryjreedy merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-93016-run-custom-args
Sep 24, 2026
Merged

terryjreedy merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-93016-run-custom-args

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

CustomRun.cli_args_ok() used shlex.split() with POSIX rules on every platform, so on Windows backslashes were treated as escape characters (c:\Users became c:Users) and single quotes as quotes, unlike python.exe, whose sys.argv follows the C runtime rules. And the previous arguments were passed as a list to the entry StringVar, which displayed them as a Tcl list ({c:users}).

On Windows, the command line is now split with the same rules as the C runtime uses (backslashes are literal unless they precede a double quote; \" is a literal quote; "" inside a quoted part is a literal quote). The new util._split_windows() was checked against the actual sys.argv of python.exe on Windows for a set of tricky inputs, and it round-trips subprocess.list2cmdline(), which is now used to display the previous arguments (shlex.join() on other platforms).

🤖 Generated with Claude Code

…ed" dialog

On Windows, split the command line as the Python executable does instead
of using the POSIX rules, so that backslashes are not escape characters.
Display previous arguments quoted and joined, not as a Tcl list.
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 only 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 16, 2026
@terryjreedy

Copy link
Copy Markdown
Member

Verified bug and fix on Windows with c:\Users, \\server\share. Merging.

@terryjreedy
terryjreedy merged commit db2d1a5 into python:main Sep 24, 2026
65 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.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka and @terryjreedy, I could not cleanly backport this to 3.15 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker db2d1a5a159b8e7862648750f80cde0b30d02f47 3.15

@bedevere-app

bedevere-app Bot commented Sep 24, 2026

Copy link
Copy Markdown

GH-158049 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 24, 2026
@bedevere-app

bedevere-app Bot commented Sep 24, 2026

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Sep 24, 2026
terryjreedy pushed a commit that referenced this pull request Sep 24, 2026
…zed" dialog (GH-157635) (#158050)

gh-93016: Fix parsing of arguments in the IDLE "Run... Customized" dialog (GH-157635)

On Windows, split the command line as the Python executable does instead
of using the POSIX rules, so that backslashes are not escape characters.
Display previous arguments quoted and joined, not as a Tcl list.
(cherry picked from commit db2d1a5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
terryjreedy pushed a commit that referenced this pull request Sep 24, 2026
…zed" dialog (GH-157635) (#158049)

gh-93016: Fix parsing of arguments in the IDLE "Run... Customized" dialog (GH-157635)

On Windows, split the command line as the Python executable does instead
of using the POSIX rules, so that backslashes are not escape characters.
Display previous arguments quoted and joined, not as a Tcl list.
(cherry picked from commit db2d1a5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@serhiy-storchaka serhiy-storchaka added needs backport to 3.15 pre-release feature fixes, bugs and security fixes and removed needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Oct 9, 2026
@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.15.
🐍🍒⛏🤖

@serhiy-storchaka
serhiy-storchaka deleted the gh-93016-run-custom-args branch October 9, 2026 19:21
@bedevere-app

bedevere-app Bot commented Oct 9, 2026

Copy link
Copy Markdown

GH-159083 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 Oct 9, 2026
serhiy-storchaka added a commit that referenced this pull request Oct 9, 2026
…zed" dialog (GH-157635) (GH-159083)

On Windows, split the command line as the Python executable does instead
of using the POSIX rules, so that backslashes are not escape characters.
Display previous arguments quoted and joined, not as a Tcl list.
(cherry picked from commit db2d1a5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
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