Handle a few more error conditions.
Klocwork 301 and 302. Will backport.
This commit is contained in:
parent
4f096d9487
commit
0c6ae5bad4
|
@ -531,11 +531,15 @@ Py_NewInterpreter(void)
|
||||||
bimod = _PyImport_FindExtension("__builtin__", "__builtin__");
|
bimod = _PyImport_FindExtension("__builtin__", "__builtin__");
|
||||||
if (bimod != NULL) {
|
if (bimod != NULL) {
|
||||||
interp->builtins = PyModule_GetDict(bimod);
|
interp->builtins = PyModule_GetDict(bimod);
|
||||||
|
if (interp->builtins == NULL)
|
||||||
|
goto handle_error;
|
||||||
Py_INCREF(interp->builtins);
|
Py_INCREF(interp->builtins);
|
||||||
}
|
}
|
||||||
sysmod = _PyImport_FindExtension("sys", "sys");
|
sysmod = _PyImport_FindExtension("sys", "sys");
|
||||||
if (bimod != NULL && sysmod != NULL) {
|
if (bimod != NULL && sysmod != NULL) {
|
||||||
interp->sysdict = PyModule_GetDict(sysmod);
|
interp->sysdict = PyModule_GetDict(sysmod);
|
||||||
|
if (interp->sysdict == NULL)
|
||||||
|
goto handle_error;
|
||||||
Py_INCREF(interp->sysdict);
|
Py_INCREF(interp->sysdict);
|
||||||
PySys_SetPath(Py_GetPath());
|
PySys_SetPath(Py_GetPath());
|
||||||
PyDict_SetItemString(interp->sysdict, "modules",
|
PyDict_SetItemString(interp->sysdict, "modules",
|
||||||
|
@ -549,6 +553,7 @@ Py_NewInterpreter(void)
|
||||||
if (!PyErr_Occurred())
|
if (!PyErr_Occurred())
|
||||||
return tstate;
|
return tstate;
|
||||||
|
|
||||||
|
handle_error:
|
||||||
/* Oops, it didn't work. Undo it all. */
|
/* Oops, it didn't work. Undo it all. */
|
||||||
|
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
|
|
Loading…
Reference in New Issue