Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 39614:9dee81dcb9b4 legacy-trunk
Handle a few more error conditions.
Klocwork 301 and 302. Will backport.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Mon, 21 Aug 2006 20:16:24 +0000 |
| parents | deb748f33c1d |
| children | da30a26dfeb3 b8fbd322760a |
comparison
equal
deleted
inserted
replaced
| 39611:17f1df1553c9 | 39614:9dee81dcb9b4 |
|---|---|
| 529 interp->modules = PyDict_New(); | 529 interp->modules = PyDict_New(); |
| 530 | 530 |
| 531 bimod = _PyImport_FindExtension("__builtin__", "__builtin__"); | 531 bimod = _PyImport_FindExtension("__builtin__", "__builtin__"); |
| 532 if (bimod != NULL) { | 532 if (bimod != NULL) { |
| 533 interp->builtins = PyModule_GetDict(bimod); | 533 interp->builtins = PyModule_GetDict(bimod); |
| 534 if (interp->builtins == NULL) | |
| 535 goto handle_error; | |
| 534 Py_INCREF(interp->builtins); | 536 Py_INCREF(interp->builtins); |
| 535 } | 537 } |
| 536 sysmod = _PyImport_FindExtension("sys", "sys"); | 538 sysmod = _PyImport_FindExtension("sys", "sys"); |
| 537 if (bimod != NULL && sysmod != NULL) { | 539 if (bimod != NULL && sysmod != NULL) { |
| 538 interp->sysdict = PyModule_GetDict(sysmod); | 540 interp->sysdict = PyModule_GetDict(sysmod); |
| 541 if (interp->sysdict == NULL) | |
| 542 goto handle_error; | |
| 539 Py_INCREF(interp->sysdict); | 543 Py_INCREF(interp->sysdict); |
| 540 PySys_SetPath(Py_GetPath()); | 544 PySys_SetPath(Py_GetPath()); |
| 541 PyDict_SetItemString(interp->sysdict, "modules", | 545 PyDict_SetItemString(interp->sysdict, "modules", |
| 542 interp->modules); | 546 interp->modules); |
| 543 _PyImportHooks_Init(); | 547 _PyImportHooks_Init(); |
| 547 } | 551 } |
| 548 | 552 |
| 549 if (!PyErr_Occurred()) | 553 if (!PyErr_Occurred()) |
| 550 return tstate; | 554 return tstate; |
| 551 | 555 |
| 556 handle_error: | |
| 552 /* Oops, it didn't work. Undo it all. */ | 557 /* Oops, it didn't work. Undo it all. */ |
| 553 | 558 |
| 554 PyErr_Print(); | 559 PyErr_Print(); |
| 555 PyThreadState_Clear(tstate); | 560 PyThreadState_Clear(tstate); |
| 556 PyThreadState_Swap(save_tstate); | 561 PyThreadState_Swap(save_tstate); |
