Issue 29644: Importing webbrowser outputs a message on stderr (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/73830

classification

Title: Importing webbrowser outputs a message on stderr
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7

process

Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: daves, ncoghlan, serhiy.storchaka
Priority: normal Keywords:

Created on 2017-02-25 05:59 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 289 merged ncoghlan,2017-02-25 07:49
Messages (8)
msg288542 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-02-25 05:59
Importing webbrowser has a side effect. It outputs a message on stderr. >>> import webbrowser /usr/bin/xdg-settings: 1: /usr/bin/xdg-settings: kreadconfig5: not found This is a regression introduced in .
msg288543 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2017-02-25 06:56
I think an appropriate way of handling this would be to route both stdout and stderr in the subprocess to subprocess.DEVNULL.
msg288544 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-02-25 07:32
Just stderr. stdout contains the requested value. And I think that an external program shouldn't be ran at import time. It would be better to defer its run until its output is required.
msg288547 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2017-02-25 07:41
Ah, and I think I'm not seeing this locally because I have both Gtk and KDE components installed (my main desktop is KDE, but Firefox and various other components are still Gtk apps).
msg288548 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-02-25 07:51
I see this because my main desktop is KDE, but optional libkf5config-bin package is not installed.
msg288549 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2017-02-25 07:56
I considered that problem of "subprocess invocation as a side-effect of import", but in this case the output is needed by the immediately following "register_X_browsers()" call, as it affects how those browsers get inserted into webbrowser._tryorder. That means there isn't any obvious way to delay it without a fairly significant refactoring of how the module works :(
msg288552 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2017-02-25 09:56
The specific problem reported has been resolved, so closing this one. If anyone's able to figure out a way to defer this to post-import somehow, I think that would make a good enhancement proposal.
msg290402 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2017-03-24 23:46
New changeset 140792bd514ee4ba739fda899785bea3ce746f05 by Nick Coghlan in branch 'master': bpo-29644: suppress subprocess output from webbrowser (#289) https://github.com/python/cpython/commit/140792bd514ee4ba739fda899785bea3ce746f05
History
Date User Action Args
2022-04-11 14:58:43 admin set github: 73830
2017-03-24 23:46:20 ncoghlan set messages: +
2017-02-25 09:56:30 ncoghlan set status: open -> closedresolution: fixedmessages: + stage: resolved
2017-02-25 07:56:53 ncoghlan set messages: +
2017-02-25 07:51:04 serhiy.storchaka set messages: +
2017-02-25 07:49:45 ncoghlan set pull_requests: + <pull%5Frequest259>
2017-02-25 07:41:13 ncoghlan set messages: +
2017-02-25 07:32:07 serhiy.storchaka set messages: +
2017-02-25 06:56:21 ncoghlan set messages: +
2017-02-25 05:59:09 serhiy.storchaka create