[pypy-svn] r11545 - in pypy/dist/pypy/objspace/std: . test

arigo at codespeak.net arigo at codespeak.net
Wed Apr 27 20:51:37 CEST 2005


Author: arigo
Date: Wed Apr 27 20:51:36 2005
New Revision: 11545

Modified:
   pypy/dist/pypy/objspace/std/listobject.py
   pypy/dist/pypy/objspace/std/test/test_listobject.py
   pypy/dist/pypy/objspace/std/test/test_sliceobject.py
Log:
- fixed a crash with list slice assignments like lst[:-3] = []
- removed an old unittest-ism in test_sliceobject.py



Modified: pypy/dist/pypy/objspace/std/listobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/listobject.py	(original)
+++ pypy/dist/pypy/objspace/std/listobject.py	Wed Apr 27 20:51:36 2005
@@ -279,7 +279,7 @@
         newsize = oldsize + delta
         _list_resize(w_list, newsize)
         w_list.ob_size = newsize
-        r = range(stop+delta, newsize)
+        r = range(start+len2, newsize)
         if delta > 0:
             r.reverse()
         items = w_list.ob_item

Modified: pypy/dist/pypy/objspace/std/test/test_listobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_listobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_listobject.py	Wed Apr 27 20:51:36 2005
@@ -388,6 +388,9 @@
         l = range(6)
         l[1:3] = 'abc'
         assert l == [0, 'a', 'b', 'c', 3, 4, 5]
+        l = []
+        l[:-3] = []
+        assert l == []
 
     def test_recursive_repr(self):
         l = []

Modified: pypy/dist/pypy/objspace/std/test/test_sliceobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_sliceobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_sliceobject.py	Wed Apr 27 20:51:36 2005
@@ -4,22 +4,17 @@
 
 class TestW_SliceObject:
 
-    def equal_indices(self, got, expected):
-        assert len(got) == len(expected)
-        for g, e in zip(got, expected):
-            assert g == e
-
     def test_indices(self):
         from pypy.objspace.std import slicetype
         space = self.space
         w = space.wrap
         w_None = space.w_None
         w_slice = space.newslice(w_None, w_None, w_None)
-        self.equal_indices(slicetype.indices3(space, w_slice, 6), (0, 6, 1))
+        assert slicetype.indices3(space, w_slice, 6) == (0, 6, 1)
         w_slice = space.newslice(w(0), w(6), w(1))
-        self.equal_indices(slicetype.indices3(space, w_slice, 6), (0, 6, 1))
+        assert slicetype.indices3(space, w_slice, 6) == (0, 6, 1)
         w_slice = space.newslice(w_None, w_None, w(-1))
-        self.equal_indices(slicetype.indices3(space, w_slice, 6), (5, -1, -1))
+        assert slicetype.indices3(space, w_slice, 6) == (5, -1, -1)
 
     def test_indices_fail(self):
         from pypy.objspace.std import slicetype



More information about the Pypy-commit mailing list