diff options
Diffstat (limited to 'Python')
-rw-r--r-- | Python/_warnings.c | 2 | ||||
-rw-r--r-- | Python/pythonrun.c | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c index f0e1e51..9453844 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 ec2c6ca..252b2d1 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -264,6 +264,9 @@ Py_InitializeEx(int install_sigs) _PyImportHooks_Init(); + /* Initialize _warnings. */ + _PyWarnings_Init(); + #if defined(HAVE_LANGINFO_H) && defined(CODESET) /* On Unix, set the file system encoding according to the user's preference, if the CODESET names a well-known @@ -284,7 +287,6 @@ Py_InitializeEx(int install_sigs) initsigs(); /* Signal handling stuff, including initintr() */ /* Initialize warnings. */ - _PyWarnings_Init(); if (PySys_HasWarnOptions()) { PyObject *warnings_module = PyImport_ImportModule("warnings"); if (!warnings_module) |