diff options
author | Guido van Rossum <guido@python.org> | 2003-04-14 20:58:14 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2003-04-14 20:58:14 (GMT) |
commit | 3a3cca5b820084d759b06aed84b1070a56786af5 (patch) | |
tree | 81809e367df89b0dbb4255be3316b7083ca31e45 /Objects/listobject.c | |
parent | b43f15e1ce34deac45eb173db5f12d3d979cf08e (diff) | |
download | cpython-3a3cca5b820084d759b06aed84b1070a56786af5.zip cpython-3a3cca5b820084d759b06aed84b1070a56786af5.tar.gz cpython-3a3cca5b820084d759b06aed84b1070a56786af5.tar.bz2 |
- 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.
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r-- | Objects/listobject.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c index 6228e64..047c6ec 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -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; ) |