diff options
author | Aarni Koskela <akx@iki.fi> | 2024-09-01 05:17:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-01 05:17:03 (GMT) |
commit | 0b6acfee04b30e7993314723c614625ddd90ae6e (patch) | |
tree | 7a571dcc9773c03885993002b78d241d41db589e | |
parent | 917283ada6fb01a3221b708d64f0a5195e1672dc (diff) | |
download | cpython-0b6acfee04b30e7993314723c614625ddd90ae6e.zip cpython-0b6acfee04b30e7993314723c614625ddd90ae6e.tar.gz cpython-0b6acfee04b30e7993314723c614625ddd90ae6e.tar.bz2 |
gh-123494: Improve documentation for ``webbrowser`` return types (#123495)
Document the return value for ``webbrowser.open*()``.
-rw-r--r-- | Doc/library/webbrowser.rst | 7 | ||||
-rw-r--r-- | Lib/webbrowser.py | 3 |
2 files changed, 10 insertions, 0 deletions
diff --git a/Doc/library/webbrowser.rst b/Doc/library/webbrowser.rst index 334f21f..4a15597 100644 --- a/Doc/library/webbrowser.rst +++ b/Doc/library/webbrowser.rst @@ -72,6 +72,8 @@ The following functions are defined: (note that under many window managers this will occur regardless of the setting of this variable). + Returns ``True`` if a browser was successfully launched, ``False`` otherwise. + Note that on some platforms, trying to open a filename using this function, may work and start the operating system's associated program. However, this is neither supported nor portable. @@ -84,11 +86,16 @@ The following functions are defined: Open *url* in a new window of the default browser, if possible, otherwise, open *url* in the only browser window. + Returns ``True`` if a browser was successfully launched, ``False`` otherwise. + + .. function:: open_new_tab(url) Open *url* in a new page ("tab") of the default browser, if possible, otherwise equivalent to :func:`open_new`. + Returns ``True`` if a browser was successfully launched, ``False`` otherwise. + .. function:: get(using=None) diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index 252ca92..d2efc72 100644 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -80,6 +80,9 @@ def open(url, new=0, autoraise=True): - 1: a new browser window. - 2: a new browser page ("tab"). If possible, autoraise raises the window (the default) or not. + + If opening the browser succeeds, return True. + If there is a problem, return False. """ if _tryorder is None: with _lock: |