mirror of https://github.com/python/cpython
prevent a rather unlikely segfault
This commit is contained in:
parent
aec4124fed
commit
e2caf1f60e
|
@ -183,9 +183,12 @@ PyList_GetItem(PyObject *op, Py_ssize_t i)
|
|||
return NULL;
|
||||
}
|
||||
if (i < 0 || i >= Py_SIZE(op)) {
|
||||
if (indexerr == NULL)
|
||||
if (indexerr == NULL) {
|
||||
indexerr = PyString_FromString(
|
||||
"list index out of range");
|
||||
if (indexerr == NULL)
|
||||
return NULL;
|
||||
}
|
||||
PyErr_SetObject(PyExc_IndexError, indexerr);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -447,9 +450,12 @@ static PyObject *
|
|||
list_item(PyListObject *a, Py_ssize_t i)
|
||||
{
|
||||
if (i < 0 || i >= Py_SIZE(a)) {
|
||||
if (indexerr == NULL)
|
||||
if (indexerr == NULL) {
|
||||
indexerr = PyString_FromString(
|
||||
"list index out of range");
|
||||
if (indexerr == NULL)
|
||||
return NULL;
|
||||
}
|
||||
PyErr_SetObject(PyExc_IndexError, indexerr);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue