Commit Graph

116 Commits

Author SHA1 Message Date
Nikita Sobolev e5d45b7444
gh-105745: Fix open method of webbrowser.Konqueror (#105746) 2023-06-14 12:29:16 +02:00
Victor Stinner 0f885ffa94
gh-105407: Remove unused imports (#105554) 2023-06-09 12:50:31 +00:00
Nikita Sobolev 947ec7ab02
gh-105545: Remove deprecated `MacOSXOSAScript._name` (gh-105546) 2023-06-09 08:52:58 +00:00
Hugo van Kemenade 5ab4bc05c4
gh-104804: Remove webbrowser.MacOSX class, deprecated in Python 3.11 (#104816)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-05-26 16:54:15 +03:00
Steve Dower fd1947ecfb
bpo-44844: Enable detection of Microsoft Edge browser in webbrowser module (GH-29908) 2023-04-04 17:00:03 +01:00
James De Bias b0422e140d
gh-102871: Remove obsolete browsers from webbrowser (#102872) 2023-03-31 11:02:47 -04:00
Icelain 3d7eb66c96
gh-101313: Add -h and --help arguments to the webbrowser module (gh-101374) 2023-03-22 21:19:52 +09:00
Jamoo721 1c9f3391b9
gh-102690: Use Edge as fallback in webbrowser instead of IE (#102691) 2023-03-15 22:52:11 -04:00
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