mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
- 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:
parent
b43f15e1ce
commit
3a3cca5b82
4 changed files with 20 additions and 6 deletions
|
|
@ -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; )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue