summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2017-09-04 21:23:23 (GMT)
committerGitHub <noreply@github.com>2017-09-04 21:23:23 (GMT)
commit1dba3789e335f06e3b01cdc84070f2e828c9b861 (patch)
tree02f9ea9136c807f1e6a120637aae3047d509409b /Lib/subprocess.py
parent703fdb837abb8e6c4df4e7070dc266383e9a7bd7 (diff)
downloadcpython-1dba3789e335f06e3b01cdc84070f2e828c9b861.zip
cpython-1dba3789e335f06e3b01cdc84070f2e828c9b861.tar.gz
cpython-1dba3789e335f06e3b01cdc84070f2e828c9b861.tar.bz2
bpo-22536 [3.6] Set filename in FileNotFoundError (#3305)
* [3.6] bpo-22536: Set the filename in FileNotFoundError. (GH-3194) Have the subprocess module set the filename in the FileNotFoundError exception raised on POSIX systems when the executable or cwd are missing. (cherry picked from commit 8621bb5d93239316f97281826461b85072ff6db7) * bpo-22536 [3.6] (GH-3202) skip non-windows tests.
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 e0a93c5..d013234 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1328,15 +1328,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)