summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/_warnings.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 16ae932450..0568af4df5 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -75,6 +75,13 @@ get_warnings_attr(_Py_Identifier *attr_id, int try_import)
}
}
else {
+ /* if we're so late into Python finalization that the module dict is
+ gone, then we can't even use PyImport_GetModule without triggering
+ an interpreter abort.
+ */
+ if (!PyThreadState_GET()->interp->modules) {
+ return NULL;
+ }
warnings_module = PyImport_GetModule(warnings_str);
if (warnings_module == NULL)
return NULL;