Skip to content

Commit 4fd89aa

Browse files
committed
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: https://bugs.python.org/issue43137 Signed-off-by: Simon McVittie <[email protected]>
1 parent 86dfb55 commit 4fd89aa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Lib/webbrowser.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,16 @@ def register_X_browsers():
462462
if shutil.which("xdg-open"):
463463
register("xdg-open", None, BackgroundBrowser("xdg-open"))
464464

465-
# The default GNOME3 browser
465+
# Opens an appropriate browser for the URL scheme according to
466+
# freedesktop.org settings (GNOME, KDE, XFCE, etc.)
467+
if shutil.which("gio"):
468+
register("gio", None, BackgroundBrowser(["gio", "open", "--", "%s"]))
469+
470+
# Equivalent of gio open before 2015
466471
if "GNOME_DESKTOP_SESSION_ID" in os.environ and shutil.which("gvfs-open"):
467472
register("gvfs-open", None, BackgroundBrowser("gvfs-open"))
468473

469-
# The default GNOME browser
474+
# The default GNOME browser before 2008
470475
if "GNOME_DESKTOP_SESSION_ID" in os.environ and shutil.which("gnome-open"):
471476
register("gnome-open", None, BackgroundBrowser("gnome-open"))
472477

0 commit comments

Comments
 (0)