]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40767: Allow pure Wayland to get default XDG web browser (GH-20382)
authorJeremy Attali <jeremy.attali@gmail.com>
Wed, 3 Jun 2020 12:42:33 +0000 (08:42 -0400)
committerGitHub <noreply@github.com>
Wed, 3 Jun 2020 12:42:33 +0000 (05:42 -0700)
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.

Lib/webbrowser.py
Misc/NEWS.d/next/Library/2020-05-27-21-27-01.bpo-40767.L5MnVV.rst [new file with mode: 0644]

index 9c73bcfb44ae81b27d081d9f9a82c08885e1f15f..3dcf66b65982507148fa0a2d681b144b3d092809 100755 (executable)
@@ -545,7 +545,7 @@ def register_standard_browsers():
                 register(browser, None, BackgroundBrowser(browser))
     else:
         # Prefer X browsers if present
-        if os.environ.get("DISPLAY"):
+        if os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY"):
             try:
                 cmd = "xdg-settings get default-web-browser".split()
                 raw_result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
diff --git a/Misc/NEWS.d/next/Library/2020-05-27-21-27-01.bpo-40767.L5MnVV.rst b/Misc/NEWS.d/next/Library/2020-05-27-21-27-01.bpo-40767.L5MnVV.rst
new file mode 100644 (file)
index 0000000..4bebb31
--- /dev/null
@@ -0,0 +1,3 @@
+:mod:`webbrowser` now properly finds the default browser in pure Wayland
+systems by checking the WAYLAND_DISPLAY environment variable. Patch
+contributed by Jérémy Attali.