mirror of
https://github.com/python/cpython.git
synced 2025-07-14 14:55:17 +00:00
Issue #10372: Import the warnings module only after the IO library is
initialized, so as to avoid bootstrap issues with the '-W' option.
This commit is contained in:
parent
81c87c5e9a
commit
cf9f98034a
3 changed files with 30 additions and 8 deletions
|
@ -299,19 +299,21 @@ Py_InitializeEx(int install_sigs)
|
|||
if (install_sigs)
|
||||
initsigs(); /* Signal handling stuff, including initintr() */
|
||||
|
||||
/* Initialize warnings. */
|
||||
if (PySys_HasWarnOptions()) {
|
||||
PyObject *warnings_module = PyImport_ImportModule("warnings");
|
||||
if (!warnings_module)
|
||||
PyErr_Clear();
|
||||
Py_XDECREF(warnings_module);
|
||||
}
|
||||
|
||||
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 == NULL) {
|
||||
fprintf(stderr, "'import warnings' failed; traceback:\n");
|
||||
PyErr_Print();
|
||||
}
|
||||
Py_XDECREF(warnings_module);
|
||||
}
|
||||
|
||||
if (!Py_NoSiteFlag)
|
||||
initsite(); /* Module site */
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue