]> granicus.if.org Git - python/commitdiff
Backport:
authorNeal Norwitz <nnorwitz@gmail.com>
Fri, 5 Jan 2007 05:28:50 +0000 (05:28 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Fri, 5 Jan 2007 05:28:50 +0000 (05:28 +0000)
Prevent crash on shutdown which can occur if we are finalizing
and the module dict has been cleared already and some object
raises a warning (like in a __del__).

Misc/NEWS
Python/errors.c

index bf793a3d2cb9f5f136f623a466cf56e9f297bab2..76ed61e83542a928d73cdc333a710b3967ba6287 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.5.1c1?
 Core and builtins
 -----------------
 
+- Prevent seg fault on shutdown which could occur if an object
+  raised a warning.
+
 - Bug #1566280: Explicitly invoke threading._shutdown from Py_Main,
   to avoid relying on atexit.
 
index 66a734eb15c7a07610463111ae970ec663cde399..f31f025112e72e58996ce6bdff8692106d0156cb 100644 (file)
@@ -640,7 +640,8 @@ PyErr_WarnEx(PyObject *category, const char *message, Py_ssize_t stack_level)
 
        if (warnings_module != NULL) {
                dict = PyModule_GetDict(warnings_module);
-               func = PyDict_GetItemString(dict, "warn");
+               if (dict != NULL)
+                       func = PyDict_GetItemString(dict, "warn");
        }
        if (func == NULL) {
                PySys_WriteStderr("warning: %s\n", message);