[issue3177] Add shutil.open

Daniel Plakhotich report at bugs.python.org
Wed Jan 17 18:05:43 EST 2018


Daniel Plakhotich <daniel.plakhotich at gmail.com> added the comment:

> tl;dr: shutil.whatever should call startfile(..., 'edit') or xdg-open; other actions implemented by startfile are not cross-platform.

xdg-open is just a shell script that calls desktop-specific launchers. The behavior of these launchers is very different when it comes to executables. There is no guarantee that calling xdg-open for a script will open it for editing.

For example, there are 3 launchers on my XFCE machine: exo-open (native for XFCE), gvfs-open (GNOME), and kde-open. When called with a .py script with shebang line and executable bit set, exo-open and kde-open open text editor, but gvfs-open launches the script. When called for a real exe, exo-open and gvfs-open launch it, but kde-open brings a message box saying that the exe will not be started for safety reasons.

***

The patch raises NoAssociatedApplicationError when xdg-open returns 3, but this error code actually means that a launcher was not found.

----------
nosy: +plakhotich

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue3177>
_______________________________________


More information about the Python-bugs-list mailing list