summaryrefslogtreecommitdiff
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2017-08-24 14:58:25 -0700
committerGitHub <noreply@github.com>2017-08-24 14:58:25 -0700
commit8621bb5d93239316f97281826461b85072ff6db7 (patch)
tree84335831455c051084816564497bc5b7f549ec83 /Lib/subprocess.py
parentde50360ac2fec81dbf733f6c3c739b39a8822a39 (diff)
downloadcpython-git-8621bb5d93239316f97281826461b85072ff6db7.tar.gz
bpo-22536: Set the filename in FileNotFoundError. (#3194)
Have the subprocess module set the filename in the FileNotFoundError exception raised on POSIX systems when the executable or cwd are missing.
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 2805ec3fa3..bafb501fcf 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1327,15 +1327,15 @@ class Popen(object):
child_exec_never_called = (err_msg == "noexec")
if child_exec_never_called:
err_msg = ""
+ # The error must be from chdir(cwd).
+ err_filename = cwd
+ else:
+ err_filename = orig_executable
if errno_num != 0:
err_msg = os.strerror(errno_num)
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)
+ err_msg += ': ' + repr(err_filename)
+ raise child_exception_type(errno_num, err_msg, err_filename)
raise child_exception_type(err_msg)