summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-01-02 19:07:15 (GMT)
committerGuido van Rossum <guido@python.org>1995-01-02 19:07:15 (GMT)
commitd7047b395e392ce9e46f9a83480ade8b37f6d5b0 (patch)
tree9dabdcc762d49aebc28d82372ca9d79bdbe23cf8 /Objects/listobject.c
parent1ae940a5870df2f706fa884afd533847f6b0b1a8 (diff)
downloadcpython-d7047b395e392ce9e46f9a83480ade8b37f6d5b0.zip
cpython-d7047b395e392ce9e46f9a83480ade8b37f6d5b0.tar.gz
cpython-d7047b395e392ce9e46f9a83480ade8b37f6d5b0.tar.bz2
Lots of minor changes. Note for mappingobject.c: the hash table pointer
can now be NULL.
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index a3e4cb9..521d1a8 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -404,7 +404,7 @@ list_ass_slice(a, ilow, ihigh, v)
d = n - (ihigh-ilow);
if (d <= 0) { /* Delete -d items; XDECREF ihigh-ilow items */
for (k = ilow; k < ihigh; k++)
- XDECREF(item[k]);
+ XDECREF(item[k]); /* bug: reentrant side effects */
if (d < 0) {
for (/*k = ihigh*/; k < a->ob_size; k++)
item[k+d] = item[k];
@@ -422,7 +422,7 @@ list_ass_slice(a, ilow, ihigh, v)
for (k = a->ob_size; --k >= ihigh; )
item[k+d] = item[k];
for (/*k = ihigh-1*/; k >= ilow; --k)
- XDECREF(item[k]);
+ XDECREF(item[k]); /* bug: side effects :-( */
a->ob_item = item;
a->ob_size += d;
}
@@ -454,6 +454,7 @@ list_ass_item(a, i, v)
int i;
object *v;
{
+ object *old_value;
if (i < 0 || i >= a->ob_size) {
err_setstr(IndexError, "list assignment index out of range");
return -1;
@@ -461,8 +462,9 @@ list_ass_item(a, i, v)
if (v == NULL)
return list_ass_slice(a, i, i+1, v);
INCREF(v);
- DECREF(a->ob_item[i]);
+ old_value = a->ob_item[i];
a->ob_item[i] = v;
+ DECREF(old_value);
return 0;
}