Mercurial > cpython-lru_cache-weakref
diff Modules/arraymodule.c @ 29163:2bb5ceef9ac3 legacy-trunk
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.
| author | Walter Dörwald <walter@livinglogic.de> |
|---|---|
| date | Sun, 18 May 2003 03:15:10 +0000 |
| parents | 22d177682ae1 |
| children | 23ad8b5d7b4a |
line wrap: on
line diff
--- a/Modules/arraymodule.c Sun May 18 02:25:07 2003 +0000 +++ b/Modules/arraymodule.c Sun May 18 03:15:10 2003 +0000 @@ -470,8 +470,11 @@ 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,
