diff options
| author | Antoine Pitrou <solipsis@pitrou.net> | 2010-11-10 13:55:25 (GMT) | 
|---|---|---|
| committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-11-10 13:55:25 (GMT) | 
| commit | cf9f98034a6bc7c55486042da1867447cfd2f0b5 (patch) | |
| tree | c1f4e79be6317a8ec7381c68cb3d43d5c07cfad2 /Python/pythonrun.c | |
| parent | 81c87c5e9a81728f4c7b022e3786ce11d53ed3c9 (diff) | |
| download | cpython-cf9f98034a6bc7c55486042da1867447cfd2f0b5.zip cpython-cf9f98034a6bc7c55486042da1867447cfd2f0b5.tar.gz cpython-cf9f98034a6bc7c55486042da1867447cfd2f0b5.tar.bz2 | |
Issue #10372: Import the warnings module only after the IO library is
initialized, so as to avoid bootstrap issues with the '-W' option.
Diffstat (limited to 'Python/pythonrun.c')
| -rw-r--r-- | Python/pythonrun.c | 16 | 
1 files changed, 9 insertions, 7 deletions
| diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 8b1e61a..784558c 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -299,19 +299,21 @@ Py_InitializeEx(int install_sigs)      if (install_sigs)          initsigs(); /* Signal handling stuff, including initintr() */ +    initmain(); /* Module __main__ */ +    if (initstdio() < 0) +        Py_FatalError( +            "Py_Initialize: can't initialize sys standard streams"); +      /* Initialize warnings. */      if (PySys_HasWarnOptions()) {          PyObject *warnings_module = PyImport_ImportModule("warnings"); -        if (!warnings_module) -            PyErr_Clear(); +        if (warnings_module == NULL) { +            fprintf(stderr, "'import warnings' failed; traceback:\n"); +            PyErr_Print(); +        }          Py_XDECREF(warnings_module);      } -    initmain(); /* Module __main__ */ -    if (initstdio() < 0) -        Py_FatalError( -            "Py_Initialize: can't initialize sys standard streams"); -      if (!Py_NoSiteFlag)          initsite(); /* Module site */  } | 
