diff options
author | Carl Friedrich Bolz-Tereick <cfbolz@gmx.de> | 2021-03-30 09:18:06 +0200 |
---|---|---|
committer | Carl Friedrich Bolz-Tereick <cfbolz@gmx.de> | 2021-03-30 09:18:06 +0200 |
commit | 6de1a662fdd168c43ae7c8e239e24355345b8be2 (patch) | |
tree | 5d678a93b427ea0c89d57387e06dc3b4902585e1 | |
parent | fix test (diff) | |
download | pypy-6de1a662fdd168c43ae7c8e239e24355345b8be2.tar.gz pypy-6de1a662fdd168c43ae7c8e239e24355345b8be2.tar.bz2 pypy-6de1a662fdd168c43ae7c8e239e24355345b8be2.zip |
fix bugs (thanks mattip)
-rw-r--r-- | pypy/objspace/std/listobject.py | 11 | ||||
-rw-r--r-- | pypy/objspace/std/test/test_listobject.py | 10 |
2 files changed, 14 insertions, 7 deletions
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py index 305455ac4d..1a97c71a6a 100644 --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -572,12 +572,11 @@ 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 isinstance(w_any, W_ListObject): - w_any.copy_into(self) - else: - # use the extend logic - self.clear(space) - self.extend(w_any) + if space.is_w(self, w_any): + return + # use the extend logic + self.clear(space) + self.extend(w_any) return oldsize = self.length() diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py index cad64120c9..c9abab808c 100644 --- a/pypy/objspace/std/test/test_listobject.py +++ b/pypy/objspace/std/test/test_listobject.py @@ -1130,11 +1130,19 @@ class AppTestListObject(object): b[i:i+1] = ['y'] assert b == ['y'] * count - def test_setslice_full_notlist(self): + def test_setslice_full(self): l = [1, 2, 3] l[::] = "abc" assert l == ['a', 'b', 'c'] + l = [1, 2, 3] + l[::] = [] + assert l == [] + + l = [1, 2, 3] + l[::] = l + assert l == [1, 2, 3] + def test_recursive_repr(self): l = [] assert repr(l) == '[]' |