Commit 17445d3f authored by Carl Friedrich Bolz-Tereick's avatar Carl Friedrich Bolz-Tereick
Browse files

fix issue #3440: when assigning the full slice of a list, evaluate the rhs

before clearing the list

--HG--
branch : release-pypy3.7-v7.x
parent 6392051e9668
Pipeline #21446 passed with stage
in 7 minutes and 8 seconds
......@@ -562,11 +562,16 @@ class W_ListObject(W_Root):
if (space.is_w(w_index.w_start, space.w_None) and
space.is_w(w_index.w_stop, space.w_None) and
space.is_w(w_index.w_step, space.w_None)):
if space.is_w(self, w_any):
return
# use the extend logic
if isinstance(w_any, W_ListObject):
if space.is_w(self, w_any):
return
w_other = w_any
else:
sequence_w = space.listview(w_any)
w_other = W_ListObject(space, sequence_w)
self.clear(space)
self.extend(w_any)
w_other.copy_into(self)
return
oldsize = self.length()
......
......@@ -1143,6 +1143,11 @@ class AppTestListObject(object):
l[::] = l
assert l == [1, 2, 3]
def test_setslice_full_bug(self):
l = [1, 2, 3]
l[::] = (x + 1 for x in l)
assert l == [2, 3, 4]
def test_recursive_repr(self):
l = []
assert repr(l) == '[]'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment