aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2003-05-18 03:15:10 +0000
committerWalter Dörwald <walter@livinglogic.de>2003-05-18 03:15:10 +0000
commit9e46abed5061729915ed39d7bb8c4d014369380e (patch)
treecffba6082397e0470ed2d2e90fd5babf9b654289 /Modules/arraymodule.c
parentTo be on the safe side, backed out any questionable iteritem changes and set ... (diff)
downloadcpython-9e46abed5061729915ed39d7bb8c4d014369380e.tar.gz
cpython-9e46abed5061729915ed39d7bb8c4d014369380e.tar.bz2
cpython-9e46abed5061729915ed39d7bb8c4d014369380e.zip
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.
Diffstat (limited to 'Modules/arraymodule.c')
-rw-r--r--Modules/arraymodule.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index c03160eabac..dcb66cf0a89 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -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,