]> granicus.if.org Git - python/commitdiff
Backport 51443:
authorNeal Norwitz <nnorwitz@gmail.com>
Mon, 21 Aug 2006 20:20:59 +0000 (20:20 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Mon, 21 Aug 2006 20:20:59 +0000 (20:20 +0000)
Handle a few more error conditions.

Klocwork 301 and 302.  Will backport.

Python/pythonrun.c

index 37feeca3f3ab8eafeefb49fd6e3f1d1a7584444b..e8f4fa2e5625b7bec1a85d957af1893c63783c5c 100644 (file)
@@ -531,11 +531,15 @@ Py_NewInterpreter(void)
        bimod = _PyImport_FindExtension("__builtin__", "__builtin__");
        if (bimod != NULL) {
                interp->builtins = PyModule_GetDict(bimod);
+               if (interp->builtins == NULL)
+                       goto handle_error;
                Py_INCREF(interp->builtins);
        }
        sysmod = _PyImport_FindExtension("sys", "sys");
        if (bimod != NULL && sysmod != NULL) {
                interp->sysdict = PyModule_GetDict(sysmod);
+               if (interp->sysdict == NULL)
+                       goto handle_error;
                Py_INCREF(interp->sysdict);
                PySys_SetPath(Py_GetPath());
                PyDict_SetItemString(interp->sysdict, "modules",
@@ -549,6 +553,7 @@ Py_NewInterpreter(void)
        if (!PyErr_Occurred())
                return tstate;
 
+handle_error:
        /* Oops, it didn't work.  Undo it all. */
 
        PyErr_Print();