fix error handling

This commit is contained in:
Benjamin Peterson 2009-05-25 20:13:36 +00:00
parent 49a6b0ef70
commit 7285a2666e
1 changed files with 4 additions and 3 deletions

View File

@ -85,11 +85,12 @@ initfuture_builtins(void)
if (itertools == NULL) if (itertools == NULL)
return; return;
/* If anything in the following loop fails, we fall through. */
for (cur_func = it_funcs; *cur_func; ++cur_func){ for (cur_func = it_funcs; *cur_func; ++cur_func){
iter_func = PyObject_GetAttrString(itertools, *cur_func); iter_func = PyObject_GetAttrString(itertools, *cur_func);
if (iter_func == NULL) if (iter_func == NULL ||
return; PyModule_AddObject(m, *cur_func+1, iter_func) < 0)
PyModule_AddObject(m, *cur_func+1, iter_func); break;
} }
Py_DECREF(itertools); Py_DECREF(itertools);
/* any other initialization needed */ /* any other initialization needed */