diff options
Diffstat (limited to 'Python/pystate.c')
-rw-r--r-- | Python/pystate.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index 8f30c94..f2924a8 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -685,7 +685,7 @@ _PyState_AddModule(PyObject* module, struct PyModuleDef* def) if (!state->modules_by_index) return -1; } - while(PyList_GET_SIZE(state->modules_by_index) <= def->m_base.m_index) + while (PyList_GET_SIZE(state->modules_by_index) <= def->m_base.m_index) if (PyList_Append(state->modules_by_index, Py_None) < 0) return -1; Py_INCREF(module); @@ -703,13 +703,11 @@ PyState_AddModule(PyObject* module, struct PyModuleDef* def) return -1; } index = def->m_base.m_index; - if (state->modules_by_index) { - if(PyList_GET_SIZE(state->modules_by_index) >= index) { - if(module == PyList_GET_ITEM(state->modules_by_index, index)) { - Py_FatalError("PyState_AddModule: Module already added!"); - return -1; - } - } + if (state->modules_by_index && + index < PyList_GET_SIZE(state->modules_by_index) && + module == PyList_GET_ITEM(state->modules_by_index, index)) { + Py_FatalError("PyState_AddModule: Module already added!"); + return -1; } return _PyState_AddModule(module, def); } |