Skip to content

Commit 9dd3340

Browse files
gh-103878: Document that the cancelled file dialog value is only falsy (GH-152429)
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>
1 parent 55a09ed commit 9dd3340

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Doc/library/dialog.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ listed below:
159159
The below functions when called create a modal, native look-and-feel dialog,
160160
wait for the user's selection, and return it.
161161
The exact return value depends on the function (see below); when the dialog is
162-
cancelled it is an empty string, an empty tuple, an empty list or ``None``.
162+
cancelled it is an empty string, an empty tuple or ``None``.
163+
The precise type of this empty value may vary between platforms and Tk
164+
versions, so test the result for truth rather than comparing it with a
165+
specific value.
163166

164167
.. function:: askopenfile(mode="r", **options)
165168
askopenfiles(mode="r", **options)
@@ -168,7 +171,7 @@ cancelled it is an empty string, an empty tuple, an empty list or ``None``.
168171
:func:`askopenfile` returns the opened file object, or ``None`` if the
169172
dialog is cancelled.
170173
:func:`askopenfiles` returns a list of the opened file objects, or an empty
171-
list if cancelled.
174+
tuple if cancelled.
172175
The files are opened in mode *mode* (read-only ``'r'`` by default).
173176

174177
.. function:: asksaveasfile(mode="w", **options)

0 commit comments

Comments
 (0)