summaryrefslogtreecommitdiff
path: root/Lib/webbrowser.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-43137: webbrowser: Replace gvfs-open and gnome-open with "gio open" ↵Simon McVittie2021-11-251-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-29154) * [bpo-43137](): webbrowser: Prefer gio open over gvfs-open gvfs-open(1) was superseded by gio(1) in 2015, and removed from GNOME releases in 2018. Debian and its derivatives like Ubuntu currently still have a compatibility shim for gvfs-open, but we plan to remove it. webbrowser prefers xdg-settings and xdg-open over gvfs-open, so this will only have any practical effect on systems where the xdg-utils package is not installed. Note that we don't check for GNOME_DESKTOP_SESSION_ID before using gio. gio does the right thing on any desktop environment that follows freedesktop.org specifications, similar to xdg-settings, so it's unnecessary to guard in this way. GNOME_DESKTOP_SESSION_ID was deprecated in 2008 and removed from upstream gnome-session in 2018 (it's still present in Debian/Ubuntu for backward compatibility, but probably shouldn't be). The replacement way to detect a desktop environment is the XDG_CURRENT_DESKTOP environment variable, which is a colon-separated sequence where the first item is the current desktop environment and the second and subsequent items (if present) are other desktop environments that it resembles or is based on. Resolves: * [bpo-43137](): webbrowser: Never invoke gnome-open gnome-open was part of GNOME 2, which was superseded in around 2010 and is unmaintained. The replacement was gvfs-open, which was subsequently replaced by gio(1) (as used in the previous commit). * [bpo-43137](): webbrowser: Don't run gvfs-open on GNOME gvfs-open was deprecated in 2015 and removed in 2018. The replacement is gio(1) (as used in a previous commit). GNOME_DESKTOP_SESSION_ID was deprecated in 2008 and removed in 2018. The replacement is XDG_CURRENT_DESKTOP (as mentioned in a previous commit). --- To test this on a typical modern Linux system, it is necessary to disable the `xdg-settings` and `xdg-open` code paths, for example with this hack: <details><summary>Hack to disable use of xdg-settings and xdg-open</summary> ```diff diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index 3244f206aa..8f6c09d1d2 100755 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -459,7 +459,7 @@ def open(self, url, new=0, autoraise=True): def register_X_browsers(): # use xdg-open if around - if shutil.which("xdg-open"): + if 0 and shutil.which("xdg-open"): register("xdg-open", None, BackgroundBrowser("xdg-open")) # Opens an appropriate browser for the URL scheme according to @@ -549,7 +549,7 @@ def register_standard_browsers(): # Prefer X browsers if present if os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY"): try: - cmd = "xdg-settings get default-web-browser".split() + cmd = "false xdg-settings get default-web-browser".split() raw_result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL) result = raw_result.decode().strip() except (FileNotFoundError, subprocess.CalledProcessError, PermissionError, NotADirectoryError) : ``` </details> I haven't attempted to assess which of the specific web browsers such as Galeon are still extant, and which ones disappeared years ago. They could almost certainly be cleaned up, but that's beyond the scope of this PR.
* bpo-42255: Deprecate webbrowser.MacOSX from Python 3.11 (GH-27837)Dong-hee Na2021-09-031-0/+3
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-44740: Lowercase "internet" and "web" where appropriate. (#27378)Mariusz Felisiak2021-07-271-1/+1
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-44059: Register the SerenityOS Browser in the webbrowser module (GH-25947)Linus Groh2021-05-061-0/+4
| | | Automerge-Triggered-By: GH:gpshead
* bpo-41754: Ignore NotADirectoryError in invocation of xdg-settings (GH-23075)Ronald Oussoren2020-11-081-1/+1
| | | | It is not clear why this can happen, but several users have mentioned getting this exception on macOS.
* bpo-41005: Fixed perrmission error (GH-20936)Krishna Chivukula2020-06-221-1/+1
| | | | | | * fixed issue 41005: webbrowser fails when xdg-settings cannot be executed Co-authored-by: KrishnaSai2020 <krishnasai.chivukula@gmal.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* bpo-41043: Escape literal part of the path for glob(). (GH-20994)Serhiy Storchaka2020-06-201-1/+1
|
* bpo-40767: Allow pure Wayland to get default XDG web browser (GH-20382)Jeremy Attali2020-06-031-1/+1
| | | | | | | Would be nice to backport to python 3.7+. I don't think it's worth the hassle to backport this all the way down to 3.10. But I'll let the maintainers decide. This is hard to test because the test setup already includes this [environment variable](https://github.com/python/cpython/blob/master/Lib/test/pythoninfo.py#L292) Let me know if something doesn't match the PR guidelines. This is my first PR in the python source code.
* bpo-40561: Add docstrings for webbrowser open functions (GH-19999)Brad Solomon2020-05-111-0/+16
| | | | Co-authored-by: Brad Solomon <brsolomon@deloitte.com> Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
* Fix typo from base to based (GH-18055)Michael Haas2020-01-191-1/+1
|
* bpo-37363: Add audit events for a range of modules (GH-14301)Steve Dower2019-06-241-2/+9
|
* bpo-35308: Fix regression where BROWSER env var is not respected. (GH-10693)Zhiming Wang2018-11-261-2/+2
| | | | | Regression introduced in e3ce695 and 25b804a, where the old parameter update_tryorder to _synthesize was first ignored, then given the opposite value in the attempt to fix bpo-31014.
* bpo-31014: Fix the webbrowser module. (GH-7267)Serhiy Storchaka2018-07-081-3/+3
| | | | | | | webbrowser._synthesize() called webbrowser.register() with outdated signature. Co-Authored-By: John Still <john@jmsdvl.com>
* bpo-34019: Fix wrong arguments for Opera Browser (#8047)Bumsik Kim2018-07-031-4/+3
| | | | | The Opera Browser was using a outdated command line invocation that resulted in an incorrect URL being opened in the browser when requested using the webbrowser module. * Correct the arguments passed to the Opera Browser when opening a new URL.
* bpo-29645: Speed up importing the webbrowser module. (#484)Serhiy Storchaka2017-03-081-79/+92
|
* bpo-29644: suppress subprocess output from webbrowser (#289)Nick Coghlan2017-02-251-1/+2
| | | | | | When checking for the default X web browser, xdg-settings may emit messages on stderr if some components (such as kreadconfig5) are unavailable. These messages aren't of interest to Python, so we just ignore them.
* bpo-24241: Improve preferred webbrowser handling (#85)David Steele2017-02-251-12/+25
| | | | | | | | | | | | | | | | | | - Add 'preferred' argument to webbrowser.register - Use xdg-settings to specify preferred X browser The first change replaces the existing undocumented tri-state 'try_order' parameter with the documented boolean keyword-only 'preferred' parameter. Setting it to True places the browser at the front of the list, preferring it as the return to a subsequent get() call. The second change adds a private `_os_preferred_browser` setting and then uses that to make the default browser reported by `xdg-settings` first in the try list when running under X (or another environment that sets the `DISPLAY` variable). This avoids the problem where the first entry in the tryorder queue otherwise defaults to xdg-open, which doesn't support the "new window" option.
* Issue #23262: The webbrowser module now supports Firefox 36+ and derivedSerhiy Storchaka2016-10-301-8/+20
| | | | browsers. Based on patch by Oleg Broytman.
* Issue #24452: Make webbrowser support Chrome on Mac OS X.Guido van Rossum2016-10-131-0/+1
|
* Issue #25005: Backout fix for #8232 because of use of unsafe ↵Steve Dower2015-09-051-111/+9
| | | | subprocess.call(shell=True)
* Issue #8232: Renamed WinFireFox to WinFirefoxSteve Dower2015-06-151-2/+2
|
* Issue #8232: webbrowser support incomplete on Windows. Patch by Brandon MilamSteve Dower2015-06-071-9/+111
|
* The webbrowser module now uses subprocess's start_new_session=True ratherGregory P. Smith2014-08-271-11/+4
| | | | than a potentially risky preexec_fn=os.setsid call.
* Issue #19936: Added executable bits or shebang lines to Python scripts whichSerhiy Storchaka2014-01-161-0/+0
|\ | | | | | | | | | | | | requires them. Disable executable bits and shebang lines in test and benchmark files in order to prevent using a random system python, and in source files of modules which don't provide command line interface. Fixed shebang lines in the unittestgui and checkpip scripts.
| * Issue #19936: Added executable bits or shebang lines to Python scripts whichSerhiy Storchaka2014-01-161-0/+0
| | | | | | | | | | | | | | requires them. Disable executable bits and shebang lines in test and benchmark files in order to prevent using a random system python, and in source files of modules which don't provide command line interface. Fixed shebang line to use python3 executable in the unittestgui script.
* | #19975: remove unused imports from webbrowser module.R David Murray2013-12-131-3/+0
| | | | | | | | Report and patch by Claudiu Popa.
* | - Issue #17536: Add to webbrowser's browser list: www-browser, x-www-browser,doko@ubuntu.com2013-03-241-0/+6
|\ \ | |/ | | | | iceweasel, iceape.
| * - Issue #17536: Add to webbrowser's browser list: www-browser, x-www-browser,doko@ubuntu.com2013-03-241-0/+6
| | | | | | | | iceweasel, iceape.
* | Issue #16996: webbrowser module now uses shutil.which() to find aSerhiy Storchaka2013-02-131-51/+20
| | | | | | | | web-browser on the executable search path.
* | Replace IOError with OSError (#16715)Andrew Svetlov2012-12-251-1/+1
| |
* | Issue #16719: Get rid of WindowsError. Use OSError insteadAndrew Svetlov2012-12-191-1/+1
| | | | | | | | Patch by Serhiy Storchaka.
* | Issue #16717: get rid of socket.error, replace with OSErrorAndrew Svetlov2012-12-181-1/+1
| |
* | #16135: Removal of OS/2 support (Remove OS2 and OS/2 references)Jesus Cea2012-10-051-11/+0
|/
* #15447: Use subprocess.DEVNULL in webbrowser, instead of openingR David Murray2012-09-031-2/+2
| | | | | | | | This eliminates a ResourceWarning, since before webbrowser was explicitly opening os.devnull and then leaving it open. Tests to follow. Patch by Anton Barkovsky.
* Merge #15509: If %action substitution produces a null string, drop it.R David Murray2012-09-031-2/+9
|\ | | | | | | | | | | | | Patch by Anton Barkovsky, comment addition by me. This shows up as a bug in 3.3 because the definition for Chrome produces such an empty string. Tests will follow.
| * #15509: If %action substitution produces a null string, drop it.R David Murray2012-09-031-2/+9
| | | | | | | | | | | | | | | | Patch by Anton Barkovsky, comment addition by me. This showed up as a bug in 3.3 because the definition for Chrome produced such an empty string. This fix is tested in 3.3+; backporting the new test suite is more trouble than it is worth.
* | Closes #15499: Sleep is hardcoded in webbrowser.UnixBrowserJesus Cea2012-08-011-10/+7
| |
* | - Issue #14493: Use gvfs-open/xdg-open in Lib/webbrowser.py.Matthias Klose2012-04-041-0/+8
| |
* | Issue 13620 - Support chrome browser in webbrowser.py module.Senthil Kumaran2011-12-211-0/+17
|/
* #12601: fix typo.Ezio Melotti2011-07-211-1/+1
|
* merge d71476b9a55d from tip, use start_new_session instead of os.setsid.Gregory P. Smith2011-03-151-7/+1
|
* Issue 10738: Fix webbrowser.Opera.raise_opts value.Terry Reedy2010-12-281-5/+1
|
* Remove conditional import of 'ic', that moduleRonald Oussoren2010-05-301-12/+0
| | | | | was removed in the transition from python 2.x to python 3.x.
* Merged revisions 80698 via svnmerge fromRonald Oussoren2010-05-021-1/+27
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r80698 | ronald.oussoren | 2010-05-02 11:48:21 +0200 (Sun, 02 May 2010) | 3 lines For for issue #7192: with this patch webbrowser.get("firefox") works on OSX ........
* convert shebang lines: python -> python3Benjamin Peterson2010-03-111-1/+1
|
* Merged revisions ↵Benjamin Peterson2009-09-111-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 74277,74321,74323,74326,74355,74465,74467,74488,74492,74513,74531,74549,74553,74625,74632,74643-74644,74647,74652,74666,74671,74727,74739 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r74277 | sean.reifschneider | 2009-08-01 18:54:55 -0500 (Sat, 01 Aug 2009) | 3 lines - Issue #6624: yArg_ParseTuple with "s" format when parsing argument with NUL: Bogus TypeError detail string. ........ r74321 | guilherme.polo | 2009-08-05 11:51:41 -0500 (Wed, 05 Aug 2009) | 1 line Easier reference to find (at least while svn continues being used). ........ r74323 | guilherme.polo | 2009-08-05 18:48:26 -0500 (Wed, 05 Aug 2009) | 1 line Typo. ........ r74326 | jesse.noller | 2009-08-05 21:05:56 -0500 (Wed, 05 Aug 2009) | 1 line Fix issue 4660: spurious task_done errors in multiprocessing, remove doc note for from_address ........ r74355 | gregory.p.smith | 2009-08-12 12:02:37 -0500 (Wed, 12 Aug 2009) | 2 lines comment typo fix ........ r74465 | vinay.sajip | 2009-08-15 18:23:12 -0500 (Sat, 15 Aug 2009) | 1 line Added section on logging to one file from multiple processes. ........ r74467 | vinay.sajip | 2009-08-15 18:34:47 -0500 (Sat, 15 Aug 2009) | 1 line Refined section on logging to one file from multiple processes. ........ r74488 | vinay.sajip | 2009-08-17 08:14:37 -0500 (Mon, 17 Aug 2009) | 1 line Further refined section on logging to one file from multiple processes. ........ r74492 | r.david.murray | 2009-08-17 14:26:49 -0500 (Mon, 17 Aug 2009) | 2 lines Issue 6685: 'toupper' -> 'upper' in cgi doc example explanation. ........ r74513 | skip.montanaro | 2009-08-18 09:37:52 -0500 (Tue, 18 Aug 2009) | 1 line missing module ref (issue6723) ........ r74531 | vinay.sajip | 2009-08-20 17:04:32 -0500 (Thu, 20 Aug 2009) | 1 line Added section on exceptions raised during logging. ........ r74549 | benjamin.peterson | 2009-08-24 12:42:36 -0500 (Mon, 24 Aug 2009) | 1 line fix pdf building by teaching latex the right encoding package ........ r74553 | r.david.murray | 2009-08-26 20:04:59 -0500 (Wed, 26 Aug 2009) | 2 lines Remove leftover text from end of sentence. ........ r74625 | benjamin.peterson | 2009-09-01 17:27:57 -0500 (Tue, 01 Sep 2009) | 1 line remove the check that classmethod's argument is a callable ........ r74632 | georg.brandl | 2009-09-03 02:27:26 -0500 (Thu, 03 Sep 2009) | 1 line #6828: fix wrongly highlighted blocks. ........ r74643 | georg.brandl | 2009-09-04 01:59:20 -0500 (Fri, 04 Sep 2009) | 2 lines Issue #2666: Handle BROWSER environment variable properly for unknown browser names in the webbrowser module. ........ r74644 | georg.brandl | 2009-09-04 02:55:14 -0500 (Fri, 04 Sep 2009) | 1 line #5047: remove Monterey support from configure. ........ r74647 | georg.brandl | 2009-09-04 03:17:04 -0500 (Fri, 04 Sep 2009) | 2 lines Issue #5275: In Cookie's Cookie.load(), properly handle non-string arguments as documented. ........ r74652 | georg.brandl | 2009-09-04 06:25:37 -0500 (Fri, 04 Sep 2009) | 1 line #6756: add some info about the "acct" parameter. ........ r74666 | georg.brandl | 2009-09-05 04:04:09 -0500 (Sat, 05 Sep 2009) | 1 line #6841: remove duplicated word. ........ r74671 | georg.brandl | 2009-09-05 11:47:17 -0500 (Sat, 05 Sep 2009) | 1 line #6843: add link from filterwarnings to where the meaning of the arguments is covered. ........ r74727 | benjamin.peterson | 2009-09-08 18:04:22 -0500 (Tue, 08 Sep 2009) | 1 line #6865 fix ref counting in initialization of pwd module ........ r74739 | georg.brandl | 2009-09-11 02:55:20 -0500 (Fri, 11 Sep 2009) | 1 line Move function back to its section. ........
* Merged revisions 74075,74187,74197,74201,74216,74225 via svnmerge fromAlexandre Vassalotti2009-07-291-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r74075 | georg.brandl | 2009-07-18 05:06:31 -0400 (Sat, 18 Jul 2009) | 1 line #6505: fix typos. ........ r74187 | benjamin.peterson | 2009-07-23 10:19:08 -0400 (Thu, 23 Jul 2009) | 1 line use bools for autoraise ........ r74197 | benjamin.peterson | 2009-07-24 22:03:48 -0400 (Fri, 24 Jul 2009) | 1 line clarify ........ r74201 | amaury.forgeotdarc | 2009-07-25 12:22:06 -0400 (Sat, 25 Jul 2009) | 2 lines Better name a variable: 'buf' seems to imply a mutable buffer. ........ r74216 | michael.foord | 2009-07-26 17:12:14 -0400 (Sun, 26 Jul 2009) | 1 line Issue 6581. Michael Foord ........ r74225 | kurt.kaiser | 2009-07-27 12:09:28 -0400 (Mon, 27 Jul 2009) | 5 lines 1. Clean workspace more thoughly before build. 2. Add url of branch we are building to 'results' webpage. (url is now available in $repo_path, could be added to failure email.) 3. Adjust permissions to improve upload reliability. ........
* simplify importsFred Drake2008-12-101-2/+1
|
* add missing importFred Drake2008-12-051-0/+1
|
* Issue #4537: webbrowser.UnixBrowser failed because this module defines an open()Amaury Forgeot d'Arc2008-12-051-1/+1
| | | | | | function which shadows the builtin. Will backport to 3.0