diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-20 21:00:34 +0000 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-20 21:00:34 +0000 |
commit | 148051a054e2e575c8c908d32ff5d49cbb12e512 (patch) | |
tree | d6ca25c351e564ef1dc609f8ca0697d943b30961 /Python | |
parent | 784c027d18a7597aeb265325330e0559f00f130f (diff) | |
download | cpython-git-148051a054e2e575c8c908d32ff5d49cbb12e512.tar.gz |
Recorded merge of revisions 81364 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r81364 | victor.stinner | 2010-05-19 22:40:50 +0200 (mer., 19 mai 2010) | 3 lines
Issue #8766: Initialize _warnings module before importing the first module.
Fix a crash if an empty directory called "encodings" exists in sys.path.
........
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 f0e1e512f5..94538443c0 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 ec2c6caea3..252b2d171b 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) |