Skip to content

gh-103878: Document that the cancelled file dialog value is only falsy#152429

Merged
serhiy-storchaka merged 4 commits into
python:mainfrom
serhiy-storchaka:filedialog-cancel-doc
Jun 29, 2026
Merged

gh-103878: Document that the cancelled file dialog value is only falsy#152429
serhiy-storchaka merged 4 commits into
python:mainfrom
serhiy-storchaka:filedialog-cancel-doc

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

The static file dialog functions return a false value when the dialog is cancelled, but its exact type is not stable: askdirectory(), for example, yields () on some platforms and "" on others (see the issue). Code that compares the result against a specific empty value is therefore fragile.

The blanket "or None" wording the issue reported was already corrected by the gh-86726 documentation overhaul. This adds a short note to the shared description advising callers to test the result for truth rather than comparing it with a specific value.

This is the documentation half of the issue; normalizing the return type itself is a separate, future-release change.

…y falsy

Its exact type (empty string, tuple, list or None) varies between
platforms and Tk versions, so advise testing the result for truth.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@read-the-docs-community

read-the-docs-community Bot commented Jun 27, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33338444 | 📁 Comparing 87263b2 against main (219f7a9)

  🔍 Preview build  

2 files changed
± library/dialog.html
± whatsnew/changelog.html

serhiy-storchaka and others added 3 commits June 27, 2026 19:52
askopenfiles() returns an empty tuple, not an empty list, when cancelled.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
No file dialog function returns an empty list on cancellation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka merged commit 9dd3340 into python:main Jun 29, 2026
30 checks passed
@miss-islington-app

Copy link
Copy Markdown

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

@serhiy-storchaka serhiy-storchaka deleted the filedialog-cancel-doc branch June 29, 2026 19:52
@bedevere-app

bedevere-app Bot commented Jun 29, 2026

Copy link
Copy Markdown

GH-152627 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 Jun 29, 2026
@bedevere-app

bedevere-app Bot commented Jun 29, 2026

Copy link
Copy Markdown

GH-152628 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 Jun 29, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Jun 29, 2026
@serhiy-storchaka serhiy-storchaka added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 29, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jun 29, 2026

Copy link
Copy Markdown

GH-152629 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 Jun 29, 2026
serhiy-storchaka added a commit that referenced this pull request Jun 29, 2026
…ly falsy (GH-152429) (GH-152628)

Its exact type (empty string, tuple, list or None) varies between
platforms and Tk versions, so advise testing the result for truth.
(cherry picked from commit 9dd3340)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jun 29, 2026
…ly falsy (GH-152429) (GH-152627)

Its exact type (empty string, tuple, list or None) varies between
platforms and Tk versions, so advise testing the result for truth.
(cherry picked from commit 9dd3340)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jun 29, 2026
…ly falsy (GH-152429) (GH-152629)

Its exact type (empty string, tuple, list or None) varies between
platforms and Tk versions, so advise testing the result for truth.
(cherry picked from commit 9dd3340)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant