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

gbrandl at codespeak.net gbrandl at codespeak.net
Fri Mar 2 15:57:55 CET 2007


Author: gbrandl
Date: Fri Mar  2 15:57:53 2007
New Revision: 39694

Modified:
   pypy/dist/pypy/objspace/std/smartresizablelist.py
   pypy/dist/pypy/objspace/std/test/test_listmultiobject.py
Log:
A small fix in smartlist.insert.



Modified: pypy/dist/pypy/objspace/std/smartresizablelist.py
==============================================================================
--- pypy/dist/pypy/objspace/std/smartresizablelist.py	(original)
+++ pypy/dist/pypy/objspace/std/smartresizablelist.py	Fri Mar  2 15:57:53 2007
@@ -169,7 +169,7 @@
 
     def insert(self, i, w_item):
         self.grow()
-        for x in range(self._length - 1, i - 1, -1):
+        for x in range(self._length - 2, i - 1, -1):
             self.setitem(x + 1, self.getitem(x))
         self.setitem(i, w_item)
         return self

Modified: pypy/dist/pypy/objspace/std/test/test_listmultiobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_listmultiobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_listmultiobject.py	Fri Mar  2 15:57:53 2007
@@ -118,3 +118,9 @@
     def setup_class(cls):
         cls.space = gettestobjspace(**{
             "objspace.std.withsmartresizablelist": True})
+
+    def test_insert_some(self):
+        ls = [1,2,3,4,5,6,7]
+        for i in range(5):
+            ls.insert(0, i)
+        assert len(ls) == 12


More information about the pypy-svn mailing list