Fix array.array.insert(), so that it treats negative indices as

being relative to the end of the array, just like list.insert() does.
This closes SF bug #739313.
This commit is contained in:
Walter Dörwald 2003-05-18 03:15:10 +00:00
parent df0d87a922
commit 9e46abed50
4 changed files with 34 additions and 3 deletions

View file

@ -470,8 +470,11 @@ ins1(arrayobject *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;
memmove(items + (where+1)*self->ob_descr->itemsize,