diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2007-01-05 05:25:22 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2007-01-05 05:25:22 (GMT) |
commit | 72cd02c04107c1bd16603d7b6451cc5e53785faf (patch) | |
tree | ddf0cffcdb4031b712bafa1391f244b7cc1b53b0 /Python | |
parent | 11a70c3c96082d3b9f63f7c81f48d9bfa2010e42 (diff) | |
download | cpython-72cd02c04107c1bd16603d7b6451cc5e53785faf.zip cpython-72cd02c04107c1bd16603d7b6451cc5e53785faf.tar.gz cpython-72cd02c04107c1bd16603d7b6451cc5e53785faf.tar.bz2 |
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.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/errors.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/errors.c b/Python/errors.c index 66a734e..f31f025 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); |