[pypy-svn] r76736 - in pypy/branch/better-map-instances/pypy/objspace/std: . test

arigo at codespeak.net arigo at codespeak.net
Thu Aug 26 09:36:51 CEST 2010


Author: arigo
Date: Thu Aug 26 09:36:49 2010
New Revision: 76736

Modified:
   pypy/branch/better-map-instances/pypy/objspace/std/mapdict.py
   pypy/branch/better-map-instances/pypy/objspace/std/test/test_mapdict.py
Log:
Test and fix.


Modified: pypy/branch/better-map-instances/pypy/objspace/std/mapdict.py
==============================================================================
--- pypy/branch/better-map-instances/pypy/objspace/std/mapdict.py	(original)
+++ pypy/branch/better-map-instances/pypy/objspace/std/mapdict.py	Thu Aug 26 09:36:49 2010
@@ -115,9 +115,11 @@
 
 class DevolvedDictTerminator(Terminator):
     def read(self, obj, selector):
-        w_dict = obj.getdict()
-        space = self.space
-        return space.finditem_str(w_dict, selector[0])
+        if selector[1] == DICT:
+            w_dict = obj.getdict()
+            space = self.space
+            return space.finditem_str(w_dict, selector[0])
+        return Terminator.read(self, obj, selector)
 
     def write(self, obj, selector, w_value):
         if selector[1] == DICT:

Modified: pypy/branch/better-map-instances/pypy/objspace/std/test/test_mapdict.py
==============================================================================
--- pypy/branch/better-map-instances/pypy/objspace/std/test/test_mapdict.py	(original)
+++ pypy/branch/better-map-instances/pypy/objspace/std/test/test_mapdict.py	Thu Aug 26 09:36:49 2010
@@ -314,6 +314,7 @@
     obj.setdictvalue(space, "a", 5)
     obj.setdictvalue(space, "b", 6)
     obj.setdictvalue(space, "c", 7)
+    obj.setdictvalue(space, "weakref", 42)
     devolve_dict(obj)
     assert obj.getdictvalue(space, "a") == 5
     assert obj.getdictvalue(space, "b") == 6
@@ -321,6 +322,8 @@
     assert obj.getslotvalue(a) == 50
     assert obj.getslotvalue(b) == 60
     assert obj.getslotvalue(c) == 70
+    assert obj.getdictvalue(space, "weakref") == 42
+    assert obj.getweakref() is None
 
     obj.setslotvalue(a, 501)
     obj.setslotvalue(b, 601)



More information about the Pypy-commit mailing list