This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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 issue24241.
msg288543 - (view) Author: Nick 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: Nick 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: Nick 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: Nick 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: Nick 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:43adminsetgithub: 73830
2017-03-24 23:46:20ncoghlansetmessages: + msg290402
2017-02-25 09:56:30ncoghlansetstatus: open -> closed
resolution: fixed
messages: + msg288552

stage: resolved
2017-02-25 07:56:53ncoghlansetmessages: + msg288549
2017-02-25 07:51:04serhiy.storchakasetmessages: + msg288548
2017-02-25 07:49:45ncoghlansetpull_requests: + pull_request259
2017-02-25 07:41:13ncoghlansetmessages: + msg288547
2017-02-25 07:32:07serhiy.storchakasetmessages: + msg288544
2017-02-25 06:56:21ncoghlansetmessages: + msg288543
2017-02-25 05:59:09serhiy.storchakacreate