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 6a3f17c9b559ab550ce41a9f69153139577c3b9c..da68f262c2de818e501802fa3cb34a5e43300f2d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -47,6 +47,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 #15902: Fix imp.load_module() accepting None as a file when loading an
index 0cc7237d2eae9b96d9e145bdea15484ae60f9316..fbe1bb7a8cb0e7b9f1f63fbe8d53fb80f4a25160 100644 (file)
@@ -344,7 +344,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,
@@ -372,8 +375,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,