summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2012-10-10 10:44:47 (GMT)
committerGregory P. Smith <greg@krypto.org>2012-10-10 10:44:47 (GMT)
commita10ddb8a5596f2184f013a751768c16a24372adb (patch)
treee4c64cbe539ce85268f9270e66d329fc858b0262 /Lib/subprocess.py
parent86b0fb23e5efa3e4bdc351d839fec353d82bb588 (diff)
parent5591b02a4c96c4b530ee024e6b1581f5ba72945d (diff)
downloadcpython-a10ddb8a5596f2184f013a751768c16a24372adb.zip
cpython-a10ddb8a5596f2184f013a751768c16a24372adb.tar.gz
cpython-a10ddb8a5596f2184f013a751768c16a24372adb.tar.bz2
Fixes Issue #16114: The subprocess module no longer provides a
misleading error message stating that args[0] did not exist when either the cwd or executable keyword arguments specified a path that did not exist.
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 775db50..57cc1a4 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1327,6 +1327,7 @@ class Popen(object):
if executable is None:
executable = args[0]
+ orig_executable = executable
# For transferring possible exec failure from child to parent.
# Data format: "exception name:hex errno:description"
@@ -1409,10 +1410,17 @@ class Popen(object):
err_msg = err_msg.decode(errors="surrogatepass")
if issubclass(child_exception_type, OSError) and hex_errno:
errno_num = int(hex_errno, 16)
+ child_exec_never_called = (err_msg == "noexec")
+ if child_exec_never_called:
+ err_msg = ""
if errno_num != 0:
err_msg = os.strerror(errno_num)
if errno_num == errno.ENOENT:
- err_msg += ': ' + repr(args[0])
+ 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)
raise child_exception_type(err_msg)