Issue #18520: Fix initstdio(), handle PySys_SetObject() failure

This commit is contained in:
Victor Stinner 2013-07-22 23:55:19 +02:00
parent 5b3b1006bb
commit ba30883f60
1 changed files with 8 additions and 2 deletions

View File

@ -1159,8 +1159,14 @@ initstdio(void)
}
PyErr_Clear(); /* Not a fatal error if codec isn't available */
PySys_SetObject("__stderr__", std);
PySys_SetObject("stderr", std);
if (PySys_SetObject("__stderr__", std) < 0) {
Py_DECREF(std);
goto error;
}
if (PySys_SetObject("stderr", std) < 0) {
Py_DECREF(std);
goto error;
}
Py_DECREF(std);
#endif