Skip to content

Commit 140792b

Browse files
authored
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.
1 parent 56a8ecc commit 140792b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Lib/webbrowser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@ def register_X_browsers():
491491
if os.environ.get("DISPLAY"):
492492
try:
493493
cmd = "xdg-settings get default-web-browser".split()
494-
result = subprocess.check_output(cmd).decode().strip()
494+
raw_result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
495+
result = raw_result.decode().strip()
495496
except (FileNotFoundError, subprocess.CalledProcessError):
496497
pass
497498
else:

0 commit comments

Comments
 (0)