Skip to content

gh-59568: Fix IDLE file dialogs for names starting with a tilde - #157624

Merged
terryjreedy merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-59568-tilde-filename
Sep 24, 2026
Merged

terryjreedy merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-59568-tilde-filename

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Tcl before version 9 does implicit tilde substitution on file names. IDLE passes the basename of the current file as -initialfile to the file dialogs, so for a file like ~template.py the native Windows dialog raised TclError: user "template.py" doesn't exist and IDLE exited, and on X11 the Save button did nothing until the file existed. The macOS dialog does not interpret the name and is not affected.

Escape a leading tilde with ./ (.\ on Windows) in defaultfilename(), as suggested in the issue, on Tcl older than 9 and non-Aqua only. Tcl 9 does not do implicit tilde substitution any more, so nothing changes there. Verified on X11 (Tk 8.6.17) and Windows (Tk 8.6.15).

🤖 Generated with Claude Code

Tcl before version 9 substitutes a leading tilde in the initial file
name, so "Save As" crashed IDLE on Windows and did not work on X11 for
such files.
@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 terryjreedy left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

On 3.13, I got 'no response' on one of insert or delete ~, but no crash, so I will soften claim.
Will not when start from console. ADDED: I think somewhat vague is good enough here for people who have
experienced the problem. I am not convinced that we have covered every possible ~ problem,
but fixing the reported one is good enough.

@terryjreedy
terryjreedy merged commit fc9df96 into python:main Sep 24, 2026
69 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 24, 2026

Copy link
Copy Markdown

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

bedevere-app Bot commented Sep 24, 2026

Copy link
Copy Markdown

GH-158055 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-158056 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
GH-157624) (#158056)

gh-59568: Fix IDLE file dialogs for names starting with a tilde (GH-157624)

Tcl before version 9, not on macOS Aqua systems, substitutes a leading tilde in a file
name.  "Save As" can fail on Windows and X11 and may crash IDLE on Windows.
(cherry picked from commit fc9df96)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
terryjreedy pushed a commit that referenced this pull request Sep 24, 2026
GH-157624) (#158055)

gh-59568: Fix IDLE file dialogs for names starting with a tilde (GH-157624)

Tcl before version 9, not on macOS Aqua systems, substitutes a leading tilde in a file
name.  "Save As" can fail on Windows and X11 and may crash IDLE on Windows.
(cherry picked from commit fc9df96)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
hugovk pushed a commit that referenced this pull request Sep 28, 2026
GH-157624) (#158054)

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