diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-05-04 21:21:09 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-05-04 21:21:09 (GMT) |
commit | 52c5f85cf9e591b3c6f8729f58e0807d88f43792 (patch) | |
tree | ca4e1ed4181321a40b8d45a9a9db6400930d62cf | |
parent | df6931dbbcf3d0a33f5469e63c9944577a7c7382 (diff) | |
parent | c8c952ce2a77343b6fe87a9534026b4b34011322 (diff) | |
download | cpython-52c5f85cf9e591b3c6f8729f58e0807d88f43792.zip cpython-52c5f85cf9e591b3c6f8729f58e0807d88f43792.tar.gz cpython-52c5f85cf9e591b3c6f8729f58e0807d88f43792.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
@@ -69,6 +69,9 @@ Core and Builtins Library ------- +- Issue #14173: Avoid crashing when reading a signal handler during + interpreter shutdown. + - Issue #15902: Fix imp.load_module() accepting None as a file when loading an extension module. diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index dd55c10..122530b 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -339,7 +339,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, @@ -367,8 +370,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, |