]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #14173: Avoid crashing when reading a signal handler during interpreter shutdown.
authorAntoine Pitrou <solipsis@pitrou.net>
Sat, 4 May 2013 21:16:59 +0000 (23:16 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 4 May 2013 21:16:59 +0000 (23:16 +0200)
Misc/NEWS
Modules/signalmodule.c

index 628ad7653864570a733a73e96d09e12a9b3fc182..0691ad33956672d440f9c9f79e633841cbdd1b62 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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
index d5d628328b1477cfe2a86a2091539391eec75b42..184b3a91a399f9557e19ea125b92eaf1eaf88e4c 100644 (file)
@@ -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,