- list.insert(i, x) now interprets negative i as it would be

interpreted by slicing, so negative values count from the end of the
  list.  This was the only place where such an interpretation was not
  placed on a list index.
This commit is contained in:
Guido van Rossum 2003-04-14 20:58:14 +00:00
parent b43f15e1ce
commit 3a3cca5b82
4 changed files with 20 additions and 6 deletions

View file

@ -159,8 +159,11 @@ ins1(PyListObject *self, int where, PyObject *v)
PyErr_NoMemory();
return -1;
}
if (where < 0)
where = 0;
if (where < 0) {
where += self->ob_size;
if (where < 0)
where = 0;
}
if (where > self->ob_size)
where = self->ob_size;
for (i = self->ob_size; --i >= where; )