[pypy-svn] r68973 - in pypy/trunk/pypy/objspace/std: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Wed Nov 4 13:08:23 CET 2009


Author: cfbolz
Date: Wed Nov  4 13:08:23 2009
New Revision: 68973

Modified:
   pypy/trunk/pypy/objspace/std/sharingdict.py
   pypy/trunk/pypy/objspace/std/test/test_sharingdict.py
Log:
Bah. I managed to write wrong code and a test that completely by chance manages
to work anyway. Fix.


Modified: pypy/trunk/pypy/objspace/std/sharingdict.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/sharingdict.py	(original)
+++ pypy/trunk/pypy/objspace/std/sharingdict.py	Wed Nov  4 13:08:23 2009
@@ -133,8 +133,8 @@
             num_back = struct_len - pos - 1
 
             if num_back > 0:
-                for i in range(pos, struct_len):
-                    self.entries[pos] = self.entries[pos + 1]
+                for i in range(pos, struct_len - 1):
+                    self.entries[i] = self.entries[i + 1]
             # don't make the entries list shorter, new keys might be added soon
             self.entries[struct_len - 1] = None
             structure = self.structure

Modified: pypy/trunk/pypy/objspace/std/test/test_sharingdict.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/test/test_sharingdict.py	(original)
+++ pypy/trunk/pypy/objspace/std/test/test_sharingdict.py	Wed Nov  4 13:08:23 2009
@@ -52,3 +52,17 @@
     d.delitem("a")
     assert d.entries == [None, None, None]
     assert d.structure.keys == {}
+
+    d = SharedDictImplementation(space)
+    d.setitem_str("a", 1)
+    d.setitem_str("b", 2)
+    d.setitem_str("c", 3)
+    d.setitem_str("d", 4)
+    d.setitem_str("e", 5)
+    d.setitem_str("f", 6)
+    d.setitem_str("g", 7)
+    d.setitem_str("h", 8)
+    d.setitem_str("i", 9)
+    d.delitem("d")
+    assert d.entries == [1, 2, 3, 5, 6, 7, 8, 9, None]
+    assert d.structure.keys == {"a": 0, "b": 1, "c": 2, "e": 3, "f": 4, "g": 5, "h": 6, "i": 7}



More information about the Pypy-commit mailing list