summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/_warnings.c2
-rw-r--r--Python/pythonrun.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c
index c49f3f3223..b1b2b71b8d 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -116,7 +116,7 @@ get_filter(PyObject *category, PyObject *text, Py_ssize_t lineno,
_filters = warnings_filters;
}
- if (!PyList_Check(_filters)) {
+ if (_filters == NULL || !PyList_Check(_filters)) {
PyErr_SetString(PyExc_ValueError,
MODULE_NAME ".filters must be a list");
return NULL;
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 58388c22d9..b469c4a625 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -265,13 +265,15 @@ Py_InitializeEx(int install_sigs)
_PyImportHooks_Init();
+ /* Initialize _warnings. */
+ _PyWarnings_Init();
+
initfsencoding();
if (install_sigs)
initsigs(); /* Signal handling stuff, including initintr() */
/* Initialize warnings. */
- _PyWarnings_Init();
if (PySys_HasWarnOptions()) {
PyObject *warnings_module = PyImport_ImportModule("warnings");
if (!warnings_module)