mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Move get_signal_name() to test.support (#121251)
* Move get_signal_name() from test.libregrtest to test.support. * Use get_signal_name() in support.script_helper. * support.script_helper now decodes stdout and stderr from UTF-8, instead of ASCII, if a command failed.
This commit is contained in:
parent
bfe0e4d769
commit
7435f053b4
6 changed files with 65 additions and 58 deletions
|
@ -685,35 +685,6 @@ def cleanup_temp_dir(tmp_dir: StrPath):
|
|||
print("Remove file: %s" % name)
|
||||
os_helper.unlink(name)
|
||||
|
||||
WINDOWS_STATUS = {
|
||||
0xC0000005: "STATUS_ACCESS_VIOLATION",
|
||||
0xC00000FD: "STATUS_STACK_OVERFLOW",
|
||||
0xC000013A: "STATUS_CONTROL_C_EXIT",
|
||||
}
|
||||
|
||||
def get_signal_name(exitcode):
|
||||
if exitcode < 0:
|
||||
signum = -exitcode
|
||||
try:
|
||||
return signal.Signals(signum).name
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
# Shell exit code (ex: WASI build)
|
||||
if 128 < exitcode < 256:
|
||||
signum = exitcode - 128
|
||||
try:
|
||||
return signal.Signals(signum).name
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
try:
|
||||
return WINDOWS_STATUS[exitcode]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return None
|
||||
|
||||
|
||||
ILLEGAL_XML_CHARS_RE = re.compile(
|
||||
'['
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue