comparison Python/pythonrun.c @ 39971:8c83fd79cee5 2.4

[Backport r51443 | neal.norwitz] Handle a few more error conditions. Klocwork 301 and 302. Will backport.
author Andrew M. Kuchling <amk@amk.ca>
date Tue, 03 Oct 2006 19:11:32 +0000
parents 54d177ede883
children e65836815791
comparison
equal deleted inserted replaced
39970:54d177ede883 39971:8c83fd79cee5
495 interp->modules = PyDict_New(); 495 interp->modules = PyDict_New();
496 496
497 bimod = _PyImport_FindExtension("__builtin__", "__builtin__"); 497 bimod = _PyImport_FindExtension("__builtin__", "__builtin__");
498 if (bimod != NULL) { 498 if (bimod != NULL) {
499 interp->builtins = PyModule_GetDict(bimod); 499 interp->builtins = PyModule_GetDict(bimod);
500 if (interp->builtins == NULL)
501 goto handle_error;
500 Py_INCREF(interp->builtins); 502 Py_INCREF(interp->builtins);
501 } 503 }
502 sysmod = _PyImport_FindExtension("sys", "sys"); 504 sysmod = _PyImport_FindExtension("sys", "sys");
503 if (bimod != NULL && sysmod != NULL) { 505 if (bimod != NULL && sysmod != NULL) {
504 interp->sysdict = PyModule_GetDict(sysmod); 506 interp->sysdict = PyModule_GetDict(sysmod);
507 if (interp->sysdict == NULL)
508 goto handle_error;
505 Py_INCREF(interp->sysdict); 509 Py_INCREF(interp->sysdict);
506 PySys_SetPath(Py_GetPath()); 510 PySys_SetPath(Py_GetPath());
507 PyDict_SetItemString(interp->sysdict, "modules", 511 PyDict_SetItemString(interp->sysdict, "modules",
508 interp->modules); 512 interp->modules);
509 _PyImportHooks_Init(); 513 _PyImportHooks_Init();
513 } 517 }
514 518
515 if (!PyErr_Occurred()) 519 if (!PyErr_Occurred())
516 return tstate; 520 return tstate;
517 521
522 handle_error:
518 /* Oops, it didn't work. Undo it all. */ 523 /* Oops, it didn't work. Undo it all. */
519 524
520 PyErr_Print(); 525 PyErr_Print();
521 PyThreadState_Clear(tstate); 526 PyThreadState_Clear(tstate);
522 PyThreadState_Swap(save_tstate); 527 PyThreadState_Swap(save_tstate);