Issue #8766: Initialize _warnings module before importing the first module.
Fix a crash if an empty directory called "encodings" exists in sys.path.
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 58388c2..b469c4a 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -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)