From 72cd02c04107c1bd16603d7b6451cc5e53785faf Mon Sep 17 00:00:00 2001 From: Neal Norwitz Date: Fri, 5 Jan 2007 05:25:22 +0000 Subject: 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__). Will backport. --- Python/errors.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Python/errors.c') diff --git a/Python/errors.c b/Python/errors.c index 66a734eb15..f31f025112 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -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); -- cgit v1.2.1