summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2002-06-19 15:44:15 (GMT)
committerMichael W. Hudson <mwh@python.net>2002-06-19 15:44:15 (GMT)
commit9c14badc5fed3c28504470ba4bd64bf7acad599f (patch)
tree2a474dbc252c8f5aa1f70d032feaeedc49d04231 /Objects/listobject.c
parentfe0ca4a0f50ca90359d3c619fad98bbe018ca7d2 (diff)
downloadcpython-9c14badc5fed3c28504470ba4bd64bf7acad599f.zip
cpython-9c14badc5fed3c28504470ba4bd64bf7acad599f.tar.gz
cpython-9c14badc5fed3c28504470ba4bd64bf7acad599f.tar.bz2
Fix the bug described in
http://mail.python.org/pipermail/python-dev/2002-June/025461.html with test cases. Also includes extended slice support for arrays, which I thought I'd already checked in but obviously not.
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 03bcaee..77349bb 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -1757,9 +1757,13 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
return -1;
}
+ /* treat L[slice(a,b)] = v _exactly_ like L[a:b] = v */
+ if (step == 1 && ((PySliceObject*)item)->step == Py_None)
+ return list_ass_slice(self, start, stop, value);
+
if (value == NULL) {
/* delete slice */
- PyObject **garbage, **item;
+ PyObject **garbage, **it;
int cur, i, j;
if (slicelength <= 0)
@@ -1788,15 +1792,15 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
cur + j + 1));
}
}
- for (cur = start + slicelength*step + 1;
+ for (cur = start + slicelength*step + 1;
cur < self->ob_size; cur++) {
PyList_SET_ITEM(self, cur - slicelength,
PyList_GET_ITEM(self, cur));
}
self->ob_size -= slicelength;
- item = self->ob_item;
- NRESIZE(item, PyObject*, self->ob_size);
- self->ob_item = item;
+ it = self->ob_item;
+ NRESIZE(it, PyObject*, self->ob_size);
+ self->ob_item = it;
for (i = 0; i < slicelength; i++) {
Py_DECREF(garbage[i]);