Skip to content

Commit c81b8c6

Browse files
miss-islingtonserhiy-storchakaclaude
authored
[3.13] gh-103878: Document that the cancelled file dialog value is only 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>
1 parent eee3ddf commit c81b8c6

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
@@ -131,7 +131,10 @@ listed below:
131131
The below functions when called create a modal, native look-and-feel dialog,
132132
wait for the user's selection, and return it.
133133
The exact return value depends on the function (see below); when the dialog is
134-
cancelled it is an empty string, an empty tuple, an empty list or ``None``.
134+
cancelled it is an empty string, an empty tuple or ``None``.
135+
The precise type of this empty value may vary between platforms and Tk
136+
versions, so test the result for truth rather than comparing it with a
137+
specific value.
135138

136139
.. function:: askopenfile(mode="r", **options)
137140
askopenfiles(mode="r", **options)
@@ -140,7 +143,7 @@ cancelled it is an empty string, an empty tuple, an empty list or ``None``.
140143
:func:`askopenfile` returns the opened file object, or ``None`` if the
141144
dialog is cancelled.
142145
:func:`askopenfiles` returns a list of the opened file objects, or an empty
143-
list if cancelled.
146+
tuple if cancelled.
144147
The files are opened in mode *mode* (read-only ``'r'`` by default).
145148

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

0 commit comments

Comments
 (0)