Content-Length: 329709 | pFad | http://github.com/python/cpython/commit/3b49c9babd61338ac050d1c7c3e4e6909eaa46d9

6A Catch OSError from 'spawnv()' in '_spawn_nt()'. · python/cpython@3b49c9b · GitHub
Skip to content

Commit 3b49c9b

Browse files
committed
Catch OSError from 'spawnv()' in '_spawn_nt()'.
Tweaked error messages in '_spawn_posix()'.
1 parent 01f5215 commit 3b49c9b

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

Lib/distutils/spawn.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,16 @@ def _spawn_nt ( cmd,
6363
print string.join ( [executable] + cmd[1:], ' ')
6464
if not dry_run:
6565
# spawn for NT requires a full path to the .exe
66-
rc = os.spawnv (os.P_WAIT, executable, cmd)
66+
try:
67+
rc = os.spawnv (os.P_WAIT, executable, cmd)
68+
except OSError, exc:
69+
# this seems to happen when the command isn't found
70+
raise DistutilsExecError, \
71+
"command '%s' failed: %s" % (cmd[0], exc[-1])
6772
if rc != 0:
68-
raise DistutilsExecError("command failed: %d" % rc)
73+
# and this reflects the command running but failing
74+
raise DistutilsExecError, \
75+
"command '%s' failed with exit status %d" % (cmd[0], rc)
6976

7077

7178

@@ -103,7 +110,7 @@ def _spawn_posix (cmd,
103110
(pid, status) = os.waitpid (pid, 0)
104111
if os.WIFSIGNALED (status):
105112
raise DistutilsExecError, \
106-
"command %s terminated by signal %d" % \
113+
"command '%s' terminated by signal %d" % \
107114
(cmd[0], os.WTERMSIG (status))
108115

109116
elif os.WIFEXITED (status):
@@ -112,14 +119,14 @@ def _spawn_posix (cmd,
112119
return # hey, it succeeded!
113120
else:
114121
raise DistutilsExecError, \
115-
"command %s failed with exit status %d" % \
122+
"command '%s' failed with exit status %d" % \
116123
(cmd[0], exit_status)
117124

118125
elif os.WIFSTOPPED (status):
119126
continue
120127

121128
else:
122129
raise DistutilsExecError, \
123-
"unknown error executing %s: termination status %d" % \
130+
"unknown error executing '%s': termination status %d" % \
124131
(cmd[0], status)
125132
# _spawn_posix ()

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/commit/3b49c9babd61338ac050d1c7c3e4e6909eaa46d9

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy