aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Friedrich Bolz-Tereick <cfbolz@gmx.de>2021-04-16 11:29:34 +0200
committerCarl Friedrich Bolz-Tereick <cfbolz@gmx.de>2021-04-16 11:29:34 +0200
commita569410a4bb93c84b5e1aa2a8a37799da2347edb (patch)
tree63c26c3978904ebd477f5f8b922ae4faa02aa3f4
parentupdate version to 7.3.5 (diff)
downloadpypy-release-pypy3.7-v7.3.5rc1.tar.gz
pypy-release-pypy3.7-v7.3.5rc1.tar.bz2
pypy-release-pypy3.7-v7.3.5rc1.zip
fix issue #3440: when assigning the full slice of a list, evaluate the rhsrelease-pypy3.7-v7.3.5rc1
before clearing the list
-rw-r--r--pypy/objspace/std/listobject.py11
-rw-r--r--pypy/objspace/std/test/test_listobject.py5
2 files changed, 13 insertions, 3 deletions
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
index 64ca527f4b..6cdebe1e2d 100644
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -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()
diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py
index 8231c6af95..78facecf81 100644
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -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) == '[]'