Skip to content

Commit ffdb32d

Browse files
committed
Replace Popen with check_call.
1 parent 671f913 commit ffdb32d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

distutils/spawn.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,17 @@ def spawn(cmd, search_path=True, verbose=False, dry_run=False, env=None):
5050
env[MACOSX_VERSION_VAR] = macosx_target_ver
5151

5252
try:
53-
proc = subprocess.Popen(cmd, env=env)
54-
proc.wait()
55-
exitcode = proc.returncode
53+
subprocess.check_call(cmd, env=env)
5654
except OSError as exc:
5755
if not DEBUG:
5856
cmd = cmd[0]
5957
raise DistutilsExecError(f"command {cmd!r} failed: {exc.args[-1]}") from exc
60-
61-
if exitcode:
58+
except subprocess.CalledProcessError as err:
6259
if not DEBUG:
6360
cmd = cmd[0]
64-
raise DistutilsExecError(f"command {cmd!r} failed with exit code {exitcode}")
61+
raise DistutilsExecError(
62+
f"command {cmd!r} failed with exit code {err.returncode}"
63+
) from err
6564

6665

6766
def find_executable(executable, path=None):

0 commit comments

Comments
 (0)