Skip to content

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

Open
serhiy-storchaka wants to merge 4 commits into
python:mainfrom
serhiy-storchaka:filedialog-cancel-doc
Open

gh-103878: Document that the cancelled file dialog value is only falsy#152429
serhiy-storchaka wants to merge 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant