mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Fix assignment of a list to a slice of itself.
This commit is contained in:
parent
4135e78204
commit
32dffaa016
1 changed files with 10 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue