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.

Title: outputs xdg-open deprecation warning
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.6
Status: open Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: desbma, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2017-05-01 12:34 by desbma, last changed 2022-04-11 14:58 by admin.

File name Uploaded Description Edit
issue30218-1.patch desbma, 2017-05-02 11:09
Messages (12)
msg292659 - (view) Author: desbma (desbma) * Date: 2017-05-01 12:34
Python 3.6.1 (default, Mar 27 2017, 00:27:06) 
[GCC 6.3.1 20170306] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import webbrowser
>>> This tool has been deprecated, use 'gio open' instead.
See 'gio help open' for more info.

A quick test reveals it is the invocation of xdg-open that outputs the warning:

$ xdg-open --version
xdg-open 1.1.0 rc3
$ xdg-open
This tool has been deprecated, use 'gio open' instead.
See 'gio help open' for more info.

It can be quite annoying because in my program the message is outputted in a ncurses UI and it messes the display.

Possible changes to fix this:
* Silence xdg-open output (pass stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL in Popen call)
* Detect and use "gio open" if available
msg292666 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-01 15:38
Seems it outputs the warning only on Gnome. Actually, xdg-open tries to run gvfs-open if it is installed and it is the tool now depreciated. This issue is fixed in mainstream. [1]

msg292742 - (view) Author: desbma (desbma) * Date: 2017-05-02 10:45
I'm on Arch Linux with Cinnamon, all packages up to date and xdg-utils 1.1.1 (

The fix you mention has not been included in a release yet, last release of xdg-utils is from 2015 (

So it likely many other Linux distributions are affected (eg. Ubuntu 16.04 LTS) and will never see a xdg-utils fix, if it is ever released.

That is why I think we should consider silencing xdg-open's output at the Popen call line. I can't think of any downside of doing so.
msg292743 - (view) Author: desbma (desbma) * Date: 2017-05-02 11:09
Also most other Popen calls in the webbrowser module already silence the called program's output, so it makes sense to do the same for the BackgroundBrowser class.

Here is a small patch for discussion.
msg293455 - (view) Author: desbma (desbma) * Date: 2017-05-10 21:49
msg293461 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-10 23:16
p = subprocess.Popen(cmdline, close_fds=True,
+                                     stdin=subprocess.DEVNULL,
+                                     stdout=subprocess.DEVNULL,
+                                     stderr=subprocess.DEVNULL,

I don't think that always hiding output for any browser is a good idea.

xdg-open is supposed to be cross-desktop (GNOME, XFCE, KDE, etc.).

Maybe a better fix is to use "gio" if available, or fallback on xdg-open otherwise? But gio is specific to GNOME no? What if the user has GNOME and KDE installed?
msg293490 - (view) Author: desbma (desbma) * Date: 2017-05-11 11:41
Why do you think this isn't a good idea?

As a user, what am supposed to do with that warning:
* about a program I have no idea I was calling (the webbrowser module abstraction is here so I don't have to think about it)
* I have no control about it's invocation
* the output comes asynchronously in my program and may be hard to link the the call

Also the specific example of this issue is a xdg-open deprecation warning, but it could be any other output that is hard for the user to take action on or understand where it's coming from.

My understanding of the *current* code is that  all graphical browsers are already started with their output tossed away ( It seems weird to keep it only for all the command line wrappers (xdg-open, gnome-open, etc.).
Of course the TTY interactive browsers have a good reason to keep it, obviously.
msg293491 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-11 11:49
> Why do you think this isn't a good idea?

If the command fails, you simplify have no idea of what happened. For example, thanks to stdout/stderr, you noticed the warning. Without stdout/stderr, the warning should be hidden.

webbrowser is already able to detect that GNOME is running and uses gvfs-open in that case. Maybe we should exchange these two blocks of code to prefer gvfs-open over xdg-open on GNOME?

    # use xdg-open if around
    if shutil.which("xdg-open"):
        register("xdg-open", None, BackgroundBrowser("xdg-open"))

    # The default GNOME3 browser
    if "GNOME_DESKTOP_SESSION_ID" in os.environ and shutil.which("gvfs-open"):
        register("gvfs-open", None, BackgroundBrowser("gvfs-open"))

Do you get the warning if you use gvfs-open?
msg293514 - (view) Author: desbma (desbma) * Date: 2017-05-11 18:42
> For example, thanks to stdout/stderr, you noticed the warning. Without stdout/stderr, the warning should be hidden.

That is true, but as a Python user, it don't need to see that warning, only the xdg-utils developers do.
I would have never seen it, and it would never have been a problem because xdg-util would have been updated to call gio open (with the commit mentioned above) long before gvfs-open is completely removed.

> Do you get the warning if you use gvfs-open?

Of course, because gvfs-open is precisely the cause of the deprecation warning

$ cat /usr/bin/gvfs-open

replacement="gio open"
help="gio help open"

>&2 echo "This tool has been deprecated, use '$replacement' instead."
>&2 echo "See '$help' for more info."
>&2 echo

if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then
  exec $help "$@:2"
  exec $replacement "$@"
msg293544 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-12 11:33
2017-05-11 20:42 GMT+02:00 desbma <>:
> Of course, because gvfs-open is precisely the cause of the deprecation warning

I don't understand something. Why do you consider that it's a Python
bug, whereas xdg-open redirects to the deprecated gvfs-open tool?

Why not reporting the bug to xdg-open?
msg293546 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-12 11:55
This bug already is fixed in develop branch of xdg-open. But the version including that fix still is not released. There may be years until it be released and main distributives update xdg-open.
msg293569 - (view) Author: desbma (desbma) * Date: 2017-05-12 20:31
The only issue with Python itself is that the output of a subprocess call hidden behind a high level abstraction is thrown into the user's face in an unexpected way.
This just does not seem to be the right thing to do to me.

The deprecation warning of xdg-open/gvfs-open is just a particular example that shows this problem.

The "what if the output is actually useful?" argument does not hold IMHO, because the all the other browser invocations in the webbrowser module (except the TTY browsers of course) are properly silenced.
Date User Action Args
2022-04-11 14:58:45adminsetgithub: 74405
2017-05-12 20:31:16desbmasetmessages: + msg293569
2017-05-12 11:55:09serhiy.storchakasetmessages: + msg293546
2017-05-12 11:33:16vstinnersetmessages: + msg293544
2017-05-11 18:42:37desbmasetmessages: + msg293514
2017-05-11 11:49:00vstinnersetmessages: + msg293491
2017-05-11 11:41:23desbmasetmessages: + msg293490
2017-05-10 23:16:15vstinnersetnosy: + vstinner
messages: + msg293461
2017-05-10 21:49:41desbmasetmessages: + msg293455
2017-05-02 11:09:04desbmasetfiles: + issue30218-1.patch
keywords: + patch
messages: + msg292743
2017-05-02 10:45:28desbmasetmessages: + msg292742
2017-05-01 15:38:07serhiy.storchakasetresolution: third party
messages: + msg292666
2017-05-01 14:35:40xiang.zhangsetnosy: + serhiy.storchaka
2017-05-01 12:36:54desbmasettype: behavior
2017-05-01 12:34:17desbmacreate