diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-05-04 21:16:59 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-05-04 21:16:59 (GMT) |
commit | d8931c375a92787662b32a5e07583a0490d8fc34 (patch) | |
tree | 8377352daa56b9dcfecf86d20447d3ce1df70587 | |
parent | a09657e94edef6e3cc31af93076e2e4b74955bef (diff) | |
download | cpython-d8931c375a92787662b32a5e07583a0490d8fc34.zip cpython-d8931c375a92787662b32a5e07583a0490d8fc34.tar.gz cpython-d8931c375a92787662b32a5e07583a0490d8fc34.tar.bz2 |
Issue #14173: Avoid crashing when reading a signal handler during interpreter shutdown.
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/signalmodule.c | 14 |
2 files changed, 14 insertions, 3 deletions
@@ -34,6 +34,9 @@ Core and Builtins Library ------- +- Issue #14173: Avoid crashing when reading a signal handler during + interpreter shutdown. + - Issue #16316: mimetypes now recognizes the .xz and .txz (.tar.xz) extensions. - Issue #17192: Restore the patch for Issue #10309 which was ommitted diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index d5d6283..184b3a9 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -321,7 +321,10 @@ signal_signal(PyObject *self, PyObject *args) Handlers[sig_num].tripped = 0; Py_INCREF(obj); Handlers[sig_num].func = obj; - return old_handler; + if (old_handler != NULL) + return old_handler; + else + Py_RETURN_NONE; } PyDoc_STRVAR(signal_doc, @@ -349,8 +352,13 @@ signal_getsignal(PyObject *self, PyObject *args) return NULL; } old_handler = Handlers[sig_num].func; - Py_INCREF(old_handler); - return old_handler; + if (old_handler != NULL) { + Py_INCREF(old_handler); + return old_handler; + } + else { + Py_RETURN_NONE; + } } PyDoc_STRVAR(getsignal_doc, |