Commit aff64ae8 authored by Jason R. Coombs's avatar Jason R. Coombs Committed by GitHub

Merge pull request #2236 from pypa/bugfix/2228-spawn-missing

Restore support for spawn when compiler is missing
parents 5e179ffc d61166f0
v49.0.1
-------
* #2228: Applied fix for pypa/distutils#3, restoring expectation that spawn will raise a DistutilsExecError when attempting to execute a missing file.
v49.1.0
-------
......
......@@ -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:
......
......@@ -126,6 +126,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'])
assert 'command does-no-exist failed' in str(ctx)
def test_suite():
return unittest.makeSuite(SpawnTestCase)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment