[Python-checkins] cpython (merge 3.3 -> default): Issue #14173: Avoid crashing when reading a signal handler during interpreter

antoine.pitrou python-checkins at python.org
Sat May 4 23:21:24 CEST 2013


http://hg.python.org/cpython/rev/753bcce45854
changeset:   83616:753bcce45854
parent:      83613:0b34fd75b937
parent:      83615:0dfd5c7d953d
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Sat May 04 23:21:09 2013 +0200
summary:
  Issue #14173: Avoid crashing when reading a signal handler during interpreter shutdown.

files:
  Misc/NEWS              |   3 +++
  Modules/signalmodule.c |  14 +++++++++++---
  2 files changed, 14 insertions(+), 3 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -69,6 +69,9 @@
 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
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -339,7 +339,10 @@
     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 @@
         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,

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list