diff --git a/Objects/listobject.c b/Objects/listobject.c --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -199,7 +199,7 @@ PyErr_BadInternalCall(); return NULL; } - if (i < 0 || i >= Py_SIZE(op)) { + if ((size_t)i >= (size_t)(Py_SIZE(op))) { if (indexerr == NULL) { indexerr = PyUnicode_FromString( "list index out of range"); @@ -223,7 +223,7 @@ PyErr_BadInternalCall(); return -1; } - if (i < 0 || i >= Py_SIZE(op)) { + if ((size_t)i >= (size_t)(Py_SIZE(op))) { Py_XDECREF(newitem); PyErr_SetString(PyExc_IndexError, "list assignment index out of range"); @@ -414,7 +414,7 @@ static PyObject * list_item(PyListObject *a, Py_ssize_t i) { - if (i < 0 || i >= Py_SIZE(a)) { + if ((size_t)i >= (size_t)(Py_SIZE(a))) { if (indexerr == NULL) { indexerr = PyUnicode_FromString( "list index out of range"); @@ -731,7 +731,7 @@ list_ass_item(PyListObject *a, Py_ssize_t i, PyObject *v) { PyObject *old_value; - if (i < 0 || i >= Py_SIZE(a)) { + if ((size_t)i >= (size_t)(Py_SIZE(a))) { PyErr_SetString(PyExc_IndexError, "list assignment index out of range"); return -1; @@ -925,7 +925,7 @@ } if (i < 0) i += Py_SIZE(self); - if (i < 0 || i >= Py_SIZE(self)) { + if ((size_t)i >= (size_t)(Py_SIZE(self))) { PyErr_SetString(PyExc_IndexError, "pop index out of range"); return NULL; }