summaryrefslogtreecommitdiffstats
path: root/Lib/distutils
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-07-07 11:11:28 (GMT)
committerGitHub <noreply@github.com>2020-07-07 11:11:28 (GMT)
commit6ae2780be0667a8dc52c4fb583171ec86067d700 (patch)
tree6bbec94ee8c4ea515d767971defd780d601f1bde /Lib/distutils
parent782f44b8fb07ec33cee148b2b6b4cf53024fe0cd (diff)
downloadcpython-6ae2780be0667a8dc52c4fb583171ec86067d700.zip
cpython-6ae2780be0667a8dc52c4fb583171ec86067d700.tar.gz
cpython-6ae2780be0667a8dc52c4fb583171ec86067d700.tar.bz2
bpo-41207 In distutils.spawn, rewrite FileNotFound (GH-21359)
Automerge-Triggered-By: @jaraco
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/spawn.py12
-rw-r--r--Lib/distutils/tests/test_spawn.py5
2 files changed, 14 insertions, 3 deletions
diff --git a/Lib/distutils/spawn.py b/Lib/distutils/spawn.py
index aad277b..0d1bd03 100644
--- a/Lib/distutils/spawn.py
+++ b/Lib/distutils/spawn.py
@@ -71,9 +71,15 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0):
env = dict(os.environ,
MACOSX_DEPLOYMENT_TARGET=cur_target)
- proc = subprocess.Popen(cmd, env=env)
- proc.wait()
- exitcode = proc.returncode
+ try:
+ proc = subprocess.Popen(cmd, env=env)
+ proc.wait()
+ exitcode = proc.returncode
+ except OSError as exc:
+ if not DEBUG:
+ cmd = cmd[0]
+ raise DistutilsExecError(
+ "command %r failed: %s" % (cmd, exc.args[-1])) from exc
if exitcode:
if not DEBUG:
diff --git a/Lib/distutils/tests/test_spawn.py b/Lib/distutils/tests/test_spawn.py
index 3647bab..4ec767b 100644
--- a/Lib/distutils/tests/test_spawn.py
+++ b/Lib/distutils/tests/test_spawn.py
@@ -124,6 +124,11 @@ class SpawnTestCase(support.TempdirManager,
rv = find_executable(program)
self.assertEqual(rv, filename)
+ def test_spawn_missing_exe(self):
+ with self.assertRaises(DistutilsExecError) as ctx:
+ spawn(['does-not-exist'])
+ self.assertIn("command 'does-not-exist' failed", str(ctx.exception))
+
def test_suite():
return unittest.makeSuite(SpawnTestCase)