Backport:
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__).
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 @@
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);