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
Improve error message of subprocess when cannot open #49175
Comments
I think the following error output unsatisfactory as it does not give me $ fetch_quals.py blah.txt
Traceback (most recent call last):
File "/home/mmokrejs/bin/fetch_quals.py", line 15, in <module>
_p1 = subprocess.Popen(['query_tracedb', 'retrieve', 'quality',
_id], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File "/usr/lib/python2.5/subprocess.py", line 594, in __init__
errread, errwrite)
File "/usr/lib/python2.5/subprocess.py", line 1091, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
$ I know now that I had to specify full path tot he binary or include |
Related, but outside python realm, this error likewise confuses: $ cat <<EOF > s.sh
#! invalid path
echo hi
EOF
$ ./s.sh
zsh: no such file or directory: ./s.sh |
(Actual command stream includes chmod +x ./s.sh) |
Improved error messages are feature requests because 1) there is no particular guarantee in the doc and 2) changes can break existing code, so should only happen in an new x.y version. When reporting behavior, it is helpful to give *minimal* code that will reproduce, either in the message if small, or attached. For example, with 3.1.2 on WixXP >>> import subprocess
>>> subprocess.Popen("xyz")
gives
WindowsError: [Error 2] The system cannot find the file specified Although in this case the literal name is in the traceback, it is not always. So I am leaving this open. Given that >>> open('xyx')
gives the more helpful
IOError: [Errno 2] No such file or directory: 'xyx' it seems it might be possible by using the io code. |
in PC/_subprocess.c, it should be enough to use PyErr_SetFromWindowsErrWithFilename() instead of PyErr_SetFromWindowsErr() |
I'm working this for platforms that use OSError. #pythonbugday2010 #myfirstpatch |
r86593 |
Note that Benjamin's commit only addresses the posix side. Amaury, do you want to fix the windows side? |
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: