Akira Li added the comment:
It would be inconsitent to provide filename only if exec is called e.g.:
>>> import subprocess
subprocess.call("not used", cwd="nonexistent")
FileNotFoundError: [Errno 2] No such file or directory: 'nonexistent'
The error message shows the filename (cwd) despite exec not being
called therefore it would be logical to provide non-None `filename`
attribute here too.
If we ignore the backward compatibility issue I've mentioned in msg231297
then the current code:
if errno_num == errno.ENOENT:
if child_exec_never_called:
# The error must be from chdir(cwd).
err_msg += ': ' + repr(cwd)
else:
err_msg += ': ' + repr(orig_executable)
raise child_exception_type(errno_num, err_msg)
could be replaced with:
if errno_num == errno.ENOENT:
if child_exec_never_called:
# The error must be from chdir(cwd).
filename = cwd
else:
filename = orig_executable
raise child_exception_type(errno_num, err_msg,
filename)
raise child_exception_type(errno_num, err_msg)
[1] https://hg.python.org/cpython/file/23ab1197df0b/Lib/subprocess.py#l1443
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue22536>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com