mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
bpo-41207 In distutils.spawn, rewrite FileNotFound (GH-21359)
Automerge-Triggered-By: @jaraco
This commit is contained in:
parent
782f44b8fb
commit
6ae2780be0
3 changed files with 15 additions and 3 deletions
|
@ -71,9 +71,15 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0):
|
||||||
env = dict(os.environ,
|
env = dict(os.environ,
|
||||||
MACOSX_DEPLOYMENT_TARGET=cur_target)
|
MACOSX_DEPLOYMENT_TARGET=cur_target)
|
||||||
|
|
||||||
proc = subprocess.Popen(cmd, env=env)
|
try:
|
||||||
proc.wait()
|
proc = subprocess.Popen(cmd, env=env)
|
||||||
exitcode = proc.returncode
|
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 exitcode:
|
||||||
if not DEBUG:
|
if not DEBUG:
|
||||||
|
|
|
@ -124,6 +124,11 @@ class SpawnTestCase(support.TempdirManager,
|
||||||
rv = find_executable(program)
|
rv = find_executable(program)
|
||||||
self.assertEqual(rv, filename)
|
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():
|
def test_suite():
|
||||||
return unittest.makeSuite(SpawnTestCase)
|
return unittest.makeSuite(SpawnTestCase)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
In distutils.spawn, restore expectation that DistutilsExecError is raised when the command is not found.
|
Loading…
Add table
Add a link
Reference in a new issue