Skip to content

Commit a0b7a56

Browse files
committed
..
1 parent fe037e3 commit a0b7a56

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

core/process.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616

1717
import libc
1818

19-
try:
20-
from os import WCOREDUMP
21-
except ImportError:
22-
WCOREDUMP = None
23-
2419
from _devbuild.gen.id_kind_asdl import Id
2520
from _devbuild.gen.runtime_asdl import (job_state_e, job_state_t,
2621
job_state_str, wait_status,
@@ -2042,12 +2037,12 @@ def NumRunning(self):
20422037
def GetSignalMessage(sig_num):
20432038
# type: (int) -> Optional[str]
20442039
"""Get signal message from libc or fallback to hard-coded."""
2045-
try:
2040+
msg = None # type: Optional[str]
2041+
2042+
if mylib.PYTHON:
20462043
msg = libc.strsignal(sig_num)
2047-
if msg:
2044+
if msg is not None:
20482045
return msg
2049-
except (SystemError, OSError):
2050-
pass
20512046

20522047
return _SIGNAL_MESSAGES.get(sig_num)
20532048

@@ -2176,9 +2171,15 @@ def WaitForOne(self, waitpid_options=0):
21762171
print('')
21772172
else:
21782173
msg = GetSignalMessage(term_sig)
2179-
if msg:
2180-
if WCOREDUMP is not None and WCOREDUMP(status):
2181-
msg += ' (core dumped)'
2174+
if msg is not None:
2175+
if mylib.PYTHON:
2176+
# WCOREDUMP is only available on some systems
2177+
try:
2178+
from os import WCOREDUMP # type: ignore
2179+
if WCOREDUMP(status):
2180+
msg = msg + ' (core dumped)'
2181+
except (ImportError, AttributeError):
2182+
pass
21822183
print_stderr(msg)
21832184

21842185
if proc:

0 commit comments

Comments
 (0)