Check return result from Py_InitModule*(). This API can fail.

Probably should be backported.
This commit is contained in:
Neal Norwitz 2006-01-19 06:09:39 +00:00
parent 8207cc7fd6
commit 1ac754fa10
80 changed files with 159 additions and 0 deletions

View file

@ -2817,6 +2817,8 @@ initimp(void)
m = Py_InitModule4("imp", imp_methods, doc_imp,
NULL, PYTHON_API_VERSION);
if (m == NULL)
goto failure;
d = PyModule_GetDict(m);
if (setint(d, "SEARCH_ERROR", SEARCH_ERROR) < 0) goto failure;

View file

@ -1107,5 +1107,7 @@ PyMODINIT_FUNC
PyMarshal_Init(void)
{
PyObject *mod = Py_InitModule("marshal", marshal_methods);
if (mod == NULL)
return;
PyModule_AddIntConstant(mod, "version", Py_MARSHAL_VERSION);
}

View file

@ -1027,6 +1027,8 @@ _PySys_Init(void)
#endif
m = Py_InitModule3("sys", sys_methods, sys_doc);
if (m == NULL)
return NULL;
sysdict = PyModule_GetDict(m);
{