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: Command name missing from exception in subprocess.Popen
Type: behavior Stage: resolved
Components: IO Versions: Python 3.1, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Improve error message of subprocess when cannot open
View: 4925
Assigned To: Nosy List: Phillip.M.Feldman, Phillip.M.Feldman@gmail.com, amaury.forgeotdarc, eric.araujo, eric.smith
Priority: normal Keywords:

Created on 2010-12-16 06:27 by Phillip.M.Feldman, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (9)
msg124108 - (view) Author: Phillip Feldman (Phillip.M.Feldman) Date: 2010-12-16 06:27
The error message "OSError: [Errno 2] No such file or directory" would be far more helpful if it specified the name of the file or directory that cannot be found.
msg124120 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-12-16 09:38
Normally the filename is part of the error message, as you can see below.
It's possible that some operations omit it, though. Which function were you calling?

>>> open('foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'foo'
msg124121 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2010-12-16 09:41
Operating systems also return this errno for many, many things unrelated to files. So while we might be able to fix this in some specific cases, in general it's not possible to add file names to all errors.

Once we know your specific case we can see if it's fixable.
msg124415 - (view) Author: Phillip M. Feldman (Phillip.M.Feldman@gmail.com) Date: 2010-12-21 03:36
I eventually determined that a call to `subprocess.Popen` was responsible
for the message, but could have determined this much more quickly if the
message had included the name of the file that could not be opened
(executed).

Phillip

On Mon, Dec 20, 2010 at 11:20 AM, Éric Araujo <report@bugs.python.org>wrote:

>
> Changes by Éric Araujo <merwok@netwok.org>:
>
>
> ----------
> components: +IO
> nosy: +eric.araujo
> versions: +Python 2.7, Python 3.1, Python 3.2 -Python 2.6
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue10715>
> _______________________________________
>
msg124416 - (view) Author: Phillip M. Feldman (Phillip.M.Feldman@gmail.com) Date: 2010-12-21 05:05
Why was this removed?

On Mon, Dec 20, 2010 at 8:30 PM, Alexander Belopolsky <
report@bugs.python.org> wrote:

>
> Changes by Alexander Belopolsky <belopolsky@users.sourceforge.net>:
>
>
> Removed file: http://bugs.python.org/file20125/unnamed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue10715>
> _______________________________________
>
msg124420 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2010-12-21 08:37
Because you're sending email as HTML, the message shows up both as plain text and as an attachment. It's the attachments that are being removed. If you could, please stop sending HTML email.
msg124421 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2010-12-21 08:40
Here's a code snippet that shows the problem:

>>> import subprocess
>>> subprocess.Popen(['foo'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/subprocess.py", line 593, in __init__
    errread, errwrite)
  File "/usr/lib/python2.5/subprocess.py", line 1079, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
msg124428 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2010-12-21 12:20
This has already been fixed in 3.2:

Python 3.2b2 (py3k:87413, Dec 21 2010, 07:09:13) 
[GCC 4.1.2 20070626 (Red Hat 4.1.2-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.Popen(['foo'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/python/py3k/Lib/subprocess.py", line 708, in __init__
    restore_signals, start_new_session)
  File "/root/python/py3k/Lib/subprocess.py", line 1323, in _execute_child
    raise child_exception_type(errno_num, err_msg)
OSError: [Errno 2] No such file or directory: 'foo'

It looks like it was changed by Benjamin in r86595. Not sure why that wasn't backported.
msg124429 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2010-12-21 12:24
That change was just a tweak. The real change was in r86593. It references issue 4925, of which this is a duplicate. I'm closing this, if you want to follow the issue add yourself to 4925.
History
Date User Action Args
2022-04-11 14:57:10adminsetgithub: 54924
2010-12-21 12:24:23eric.smithsetstatus: open -> closed
nosy: amaury.forgeotdarc, eric.smith, eric.araujo, Phillip.M.Feldman@gmail.com, Phillip.M.Feldman
messages: + msg124429

superseder: Improve error message of subprocess when cannot open
resolution: duplicate
stage: needs patch -> resolved
2010-12-21 12:20:37eric.smithsetnosy: amaury.forgeotdarc, eric.smith, eric.araujo, Phillip.M.Feldman@gmail.com, Phillip.M.Feldman
messages: + msg124428
versions: - Python 3.2
2010-12-21 08:41:47eric.smithsetnosy: amaury.forgeotdarc, eric.smith, eric.araujo, Phillip.M.Feldman@gmail.com, Phillip.M.Feldman
stage: needs patch
2010-12-21 08:41:24eric.smithsetnosy: amaury.forgeotdarc, eric.smith, eric.araujo, Phillip.M.Feldman@gmail.com, Phillip.M.Feldman
title: uninformative error message -> Command name missing from exception in subprocess.Popen
2010-12-21 08:40:09eric.smithsetnosy: amaury.forgeotdarc, eric.smith, eric.araujo, Phillip.M.Feldman@gmail.com, Phillip.M.Feldman
messages: + msg124421
2010-12-21 08:37:26eric.smithsetnosy: amaury.forgeotdarc, eric.smith, eric.araujo, Phillip.M.Feldman@gmail.com, Phillip.M.Feldman
messages: + msg124420
2010-12-21 08:36:44eric.smithsetfiles: - unnamed
nosy: amaury.forgeotdarc, eric.smith, eric.araujo, Phillip.M.Feldman@gmail.com, Phillip.M.Feldman
2010-12-21 05:05:40Phillip.M.Feldman@gmail.comsetfiles: + unnamed

messages: + msg124416
nosy: amaury.forgeotdarc, eric.smith, eric.araujo, Phillip.M.Feldman@gmail.com, Phillip.M.Feldman
2010-12-21 04:30:02belopolskysetfiles: - unnamed
nosy: amaury.forgeotdarc, eric.smith, eric.araujo, Phillip.M.Feldman@gmail.com, Phillip.M.Feldman
2010-12-21 03:36:42Phillip.M.Feldman@gmail.comsetfiles: + unnamed

messages: + msg124415
nosy: + Phillip.M.Feldman@gmail.com
2010-12-20 19:20:24eric.araujosetnosy: + eric.araujo

components: + IO
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
2010-12-16 09:41:28eric.smithsetnosy: + eric.smith
messages: + msg124121
2010-12-16 09:38:28amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg124120
2010-12-16 06:27:34Phillip.M.Feldmancreate