diff options
author | Guido van Rossum <guido@python.org> | 1991-12-24 13:27:34 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1991-12-24 13:27:34 (GMT) |
commit | 32dffaa0164761fb94cffa32cfe01b3d0a83bf18 (patch) | |
tree | 823a2abddb6dda9675daa42cbfdc638ae312ae24 /Objects/listobject.c | |
parent | 4135e782041517e2de473fd9b6f5375878c48e68 (diff) | |
download | cpython-32dffaa0164761fb94cffa32cfe01b3d0a83bf18.zip cpython-32dffaa0164761fb94cffa32cfe01b3d0a83bf18.tar.gz cpython-32dffaa0164761fb94cffa32cfe01b3d0a83bf18.tar.bz2 |
Fix assignment of a list to a slice of itself.
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r-- | Objects/listobject.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c index 2e2b9a2..5811f40 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -357,8 +357,17 @@ list_ass_slice(a, ilow, ihigh, v) #define b ((listobject *)v) if (v == NULL) n = 0; - else if (is_listobject(v)) + else if (is_listobject(v)) { n = b->ob_size; + if (a == b) { + /* Special case "a[i:j] = a" -- copy b first */ + int ret; + v = list_slice(b, 0, n); + ret = list_ass_slice(a, ilow, ihigh, v); + DECREF(v); + return ret; + } + } else { err_badarg(); return -1; |