New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
webbrowser.open outputs xdg-open deprecation warning #74405
Comments
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
>>> webbrowser.open("https://www.google.com")
True
>>> 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 https://www.google.com
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:
|
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] [1] https://cgit.freedesktop.org/xdg/xdg-utils/commit/?id=0d6eebb27c562e8644ccf616ebdbddf82d0d2dd8 |
I'm on Arch Linux with Cinnamon, all packages up to date and xdg-utils 1.1.1 (https://www.archlinux.org/packages/extra/any/xdg-utils/). The fix you mention has not been included in a release yet, last release of xdg-utils is from 2015 (https://portland.freedesktop.org/download/). 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. |
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. |
Ping |
p = subprocess.Popen(cmdline, close_fds=True,
+ stdin=subprocess.DEVNULL,
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL,
start_new_session=True) 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? |
Why do you think this isn't a good idea? As a user, what am supposed to do with that warning:
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 (https://hg.python.org/cpython/file/tip/Lib/webbrowser.py#l196). It seems weird to keep it only for all the command line wrappers (xdg-open, gnome-open, etc.). |
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? |
That is true, but as a Python user, it don't need to see that warning, only the xdg-utils developers do.
Of course, because gvfs-open is precisely the cause of the deprecation warning $ cat /usr/bin/gvfs-open
#!/bin/sh replacement="gio open"
help="gio help open"
if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then
exec $help "$@:2"
else
exec $replacement "$@"
fi |
2017-05-11 20:42 GMT+02:00 desbma <report@bugs.python.org>:
I don't understand something. Why do you consider that it's a Python Why not reporting the bug to xdg-open? |
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. |
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. 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. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: