Skip to content

Commit 0b6acfe

Browse files
authored
gh-123494: Improve documentation for webbrowser return types (#123495)
Document the return value for ``webbrowser.open*()``.
1 parent 917283a commit 0b6acfe

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Doc/library/webbrowser.rst

+7
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ The following functions are defined:
7272
(note that under many window managers this will occur regardless of the
7373
setting of this variable).
7474

75+
Returns ``True`` if a browser was successfully launched, ``False`` otherwise.
76+
7577
Note that on some platforms, trying to open a filename using this function,
7678
may work and start the operating system's associated program. However, this
7779
is neither supported nor portable.
@@ -84,11 +86,16 @@ The following functions are defined:
8486
Open *url* in a new window of the default browser, if possible, otherwise, open
8587
*url* in the only browser window.
8688

89+
Returns ``True`` if a browser was successfully launched, ``False`` otherwise.
90+
91+
8792
.. function:: open_new_tab(url)
8893

8994
Open *url* in a new page ("tab") of the default browser, if possible, otherwise
9095
equivalent to :func:`open_new`.
9196

97+
Returns ``True`` if a browser was successfully launched, ``False`` otherwise.
98+
9299

93100
.. function:: get(using=None)
94101

Lib/webbrowser.py

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ def open(url, new=0, autoraise=True):
8080
- 1: a new browser window.
8181
- 2: a new browser page ("tab").
8282
If possible, autoraise raises the window (the default) or not.
83+
84+
If opening the browser succeeds, return True.
85+
If there is a problem, return False.
8386
"""
8487
if _tryorder is None:
8588
with _lock:

0 commit comments

Comments
 (0)