Commit Graph

108 Commits

Author SHA1 Message Date
Simon McVittie dd50316e45
bpo-43137: Revert "webbrowser: Don't run gvfs-open on GNOME" (GH-30417)
gvfs-open was deprecated in 2015 and removed in 2018, but its replacement,
gio(1), is not available in Ubuntu 16.04, which is apparently still
supported by CPython upstream even though it is considered to be EOL by
Ubuntu developers.

Signed-off-by: Simon McVittie <smcv@debian.org>
2022-01-05 11:53:23 +00:00
Nikita Sobolev d12bec6993
bpo-43424: Deprecate `webbrowser.MacOSXOSAScript._name` attribute (GH-30241) 2021-12-30 10:30:13 +09:00
Simon McVittie 97dcab7832
bpo-43137: webbrowser: Replace gvfs-open and gnome-open with "gio open" (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.
2021-11-25 12:49:48 -08:00
Dong-hee Na bc1c49fa94
bpo-42255: Deprecate webbrowser.MacOSX from Python 3.11 (GH-27837)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-09-03 18:21:03 +02:00
Mariusz Felisiak 11749e2dc2
bpo-44740: Lowercase "internet" and "web" where appropriate. (#27378)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-07-27 00:11:55 +02:00
Linus Groh 329a47f052
bpo-44059: Register the SerenityOS Browser in the webbrowser module (GH-25947)
Automerge-Triggered-By: GH:gpshead
2021-05-06 12:01:12 -07:00
Ronald Oussoren 23831a7a90
bpo-41754: Ignore NotADirectoryError in invocation of xdg-settings (GH-23075)
It is not clear why this can happen, but several users have mentioned
getting this exception on macOS.
2020-11-08 10:46:55 +01:00
Krishna Chivukula 9e27bc0c1e
bpo-41005: Fixed perrmission error (GH-20936)
* 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>
2020-06-22 11:06:07 +02:00
Serhiy Storchaka 9355868458
bpo-41043: Escape literal part of the path for glob(). (GH-20994) 2020-06-20 11:10:31 +03:00
Jeremy Attali c822efeda9
bpo-40767: Allow pure Wayland to get default XDG web browser (GH-20382)
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.
2020-06-03 05:42:33 -07:00
Brad Solomon ef7973a981
bpo-40561: Add docstrings for webbrowser open functions (GH-19999)
Co-authored-by: Brad Solomon <brsolomon@deloitte.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2020-05-11 14:50:11 -04:00
Michael Haas 558f078911 Fix typo from base to based (GH-18055) 2020-01-19 05:29:42 -05:00
Steve Dower 60419a7e96
bpo-37363: Add audit events for a range of modules (GH-14301) 2019-06-24 08:42:54 -07:00
Zhiming Wang 8c281ed403 bpo-35308: Fix regression where BROWSER env var is not respected. (GH-10693)
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.
2018-11-26 23:29:45 +02:00
Serhiy Storchaka 25b804a9c2
bpo-31014: Fix the webbrowser module. (GH-7267)
webbrowser._synthesize() called webbrowser.register() with
outdated signature.

Co-Authored-By: John Still <john@jmsdvl.com>
2018-07-08 10:22:32 +03:00
Bumsik Kim 3cf1f154ed bpo-34019: Fix wrong arguments for Opera Browser (#8047)
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.
2018-07-03 12:30:06 +01:00
Serhiy Storchaka a7cba27aea bpo-29645: Speed up importing the webbrowser module. (#484) 2017-03-08 17:15:54 +02:00
Nick Coghlan 140792bd51 bpo-29644: suppress subprocess output from webbrowser (#289)
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.
2017-02-25 18:40:07 +10:00
David Steele e3ce69522f bpo-24241: Improve preferred webbrowser handling (#85)
- 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.
2017-02-25 14:47:38 +10:00
Serhiy Storchaka c9b750d249 Issue #23262: The webbrowser module now supports Firefox 36+ and derived
browsers.  Based on patch by Oleg Broytman.
2016-10-30 19:16:33 +02:00
Guido van Rossum b1a751b5c2 Issue #24452: Make webbrowser support Chrome on Mac OS X. 2016-10-13 11:17:27 -07:00
Steve Dower 2ebd8f5194 Issue #25005: Backout fix for #8232 because of use of unsafe subprocess.call(shell=True) 2015-09-05 11:57:47 -07:00
Steve Dower f3291a8340 Issue #8232: Renamed WinFireFox to WinFirefox 2015-06-15 09:11:14 -07:00
Steve Dower 93cfeb93ac Issue #8232: webbrowser support incomplete on Windows. Patch by Brandon Milam 2015-06-07 21:35:39 -07:00
Gregory P. Smith feac3980ce The webbrowser module now uses subprocess's start_new_session=True rather
than a potentially risky preexec_fn=os.setsid call.
2014-08-27 09:34:38 -07:00
Serhiy Storchaka 8f8ec92de8 Issue #19936: Added executable bits or shebang lines to Python scripts which
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.
2014-01-16 17:33:23 +02:00
Serhiy Storchaka b992a0e102 Issue #19936: Added executable bits or shebang lines to Python scripts which
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.
2014-01-16 17:15:49 +02:00
R David Murray b05d69808e #19975: remove unused imports from webbrowser module.
Report and patch by Claudiu Popa.
2013-12-13 17:21:42 -05:00
doko@ubuntu.com f85aca8d1e - Issue #17536: Add to webbrowser's browser list: www-browser, x-www-browser,
iceweasel, iceape.
2013-03-24 18:50:23 +01:00
doko@ubuntu.com 945c3bbf42 - Issue #17536: Add to webbrowser's browser list: www-browser, x-www-browser,
iceweasel, iceape.
2013-03-24 18:46:49 +01:00
Serhiy Storchaka 540dcba28b Issue #16996: webbrowser module now uses shutil.which() to find a
web-browser on the executable search path.
2013-02-13 12:19:40 +02:00
Andrew Svetlov f7a17b48d7 Replace IOError with OSError (#16715) 2012-12-25 16:47:37 +02:00
Andrew Svetlov 2606a6f197 Issue #16719: Get rid of WindowsError. Use OSError instead
Patch by Serhiy Storchaka.
2012-12-19 14:33:35 +02:00
Andrew Svetlov 0832af6628 Issue #16717: get rid of socket.error, replace with OSError 2012-12-18 23:10:48 +02:00
Jesus Cea f1af705720 #16135: Removal of OS/2 support (Remove OS2 and OS/2 references) 2012-10-05 02:48:46 +02:00
R David Murray 02ca144b92 #15447: Use subprocess.DEVNULL in webbrowser, instead of opening
This eliminates a ResourceWarning, since before webbrowser was
explicitly opening os.devnull and then leaving it open.  Tests
to follow.

Patch by Anton Barkovsky.
2012-09-03 12:44:29 -04:00
R David Murray d674a770e9 Merge #15509: If %action substitution produces a null string, drop it.
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.
2012-09-03 12:37:59 -04:00
R David Murray 94dd7cb0c7 #15509: If %action substitution produces a null string, drop it.
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.
2012-09-03 12:30:12 -04:00
Jesus Cea c9aa321a01 Closes #15499: Sleep is hardcoded in webbrowser.UnixBrowser 2012-08-01 03:57:52 +02:00
Matthias Klose da80b1eb2f - Issue #14493: Use gvfs-open/xdg-open in Lib/webbrowser.py. 2012-04-04 14:19:04 +02:00
Senthil Kumaran ea6b4187cf Issue 13620 - Support chrome browser in webbrowser.py module. 2011-12-21 22:20:32 +08:00
Ezio Melotti 1beea5b7c1 #12601: fix typo. 2011-07-21 11:16:32 +03:00
Gregory P. Smith 8f7724f9a4 merge d71476b9a55d from tip, use start_new_session instead of os.setsid. 2011-03-15 15:24:43 -04:00
Terry Reedy dad532f7de Issue 10738: Fix webbrowser.Opera.raise_opts value. 2010-12-28 19:30:19 +00:00
Ronald Oussoren 32eb864d31 Remove conditional import of 'ic', that module
was removed in the transition from python 2.x to
python 3.x.
2010-05-30 15:46:48 +00:00
Ronald Oussoren 4d39f6e09a Merged revisions 80698 via svnmerge from
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
........
2010-05-02 09:54:35 +00:00
Benjamin Peterson 90f5ba538b convert shebang lines: python -> python3 2010-03-11 22:53:45 +00:00
Benjamin Peterson 8719ad5dde Merged revisions 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.
........
2009-09-11 22:24:02 +00:00
Alexandre Vassalotti e223eb8477 Merged revisions 74075,74187,74197,74201,74216,74225 via svnmerge from
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.
........
2009-07-29 20:12:15 +00:00
Fred Drake ee763951dc simplify imports 2008-12-10 06:02:39 +00:00