diff Python/pythonrun.c @ 61757:deed5fce82d6

Issue #8766: Initialize _warnings module before importing the first module. Fix a crash if an empty directory called "encodings" exists in sys.path.
author Victor Stinner <victor.stinner@haypocalc.com>
date Wed, 19 May 2010 20:40:50 +0000
parents 942b3c168f15
children 815ba3872f85
line wrap: on
line diff
--- a/Python/pythonrun.c	Wed May 19 17:15:50 2010 +0000
+++ b/Python/pythonrun.c	Wed May 19 20:40:50 2010 +0000
@@ -265,13 +265,15 @@
 
     _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)