PyModule_GetDict() can fail, produce fatal errors if this happens on startup.

Klocwork #298-299.
This commit is contained in:
Neal Norwitz 2006-08-12 03:17:41 +00:00
parent b88cfad318
commit 0f7dbf731a
1 changed files with 4 additions and 0 deletions

View File

@ -203,12 +203,16 @@ Py_InitializeEx(int install_sigs)
if (bimod == NULL)
Py_FatalError("Py_Initialize: can't initialize __builtin__");
interp->builtins = PyModule_GetDict(bimod);
if (interp->builtins == NULL)
Py_FatalError("Py_Initialize: can't initialize builtins dict");
Py_INCREF(interp->builtins);
sysmod = _PySys_Init();
if (sysmod == NULL)
Py_FatalError("Py_Initialize: can't initialize sys");
interp->sysdict = PyModule_GetDict(sysmod);
if (interp->sysdict == NULL)
Py_FatalError("Py_Initialize: can't initialize sys dict");
Py_INCREF(interp->sysdict);
_PyImport_FixupExtension("sys", "sys");
PySys_SetPath(Py_GetPath());