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

cfbolz at codespeak.net cfbolz at codespeak.net
Fri Oct 29 13:48:11 CEST 2010


Author: cfbolz
Date: Fri Oct 29 13:48:09 2010
New Revision: 78464

Modified:
   pypy/trunk/pypy/objspace/std/mapdict.py
   pypy/trunk/pypy/objspace/std/test/test_mapdict.py
Log:
fix failing weakref assertion error


Modified: pypy/trunk/pypy/objspace/std/mapdict.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/mapdict.py	(original)
+++ pypy/trunk/pypy/objspace/std/mapdict.py	Fri Oct 29 13:48:09 2010
@@ -361,7 +361,8 @@
 
     def setweakref(self, space, weakreflifeline):
         from pypy.module._weakref.interp__weakref import WeakrefLifeline
-        assert isinstance(weakreflifeline, WeakrefLifeline)
+        assert (isinstance(weakreflifeline, WeakrefLifeline) or
+                    weakreflifeline is None)
         self._get_mapdict_map().write(self, ("weakref", SPECIAL), weakreflifeline)
 
 class ObjectMixin(object):

Modified: pypy/trunk/pypy/objspace/std/test/test_mapdict.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/test/test_mapdict.py	(original)
+++ pypy/trunk/pypy/objspace/std/test/test_mapdict.py	Fri Oct 29 13:48:09 2010
@@ -160,6 +160,13 @@
     assert obj.getweakref() is lifeline1
     assert obj.getdictvalue(space, "weakref") == 41
 
+    lifeline1 = WeakrefLifeline(space)
+    obj = c.instantiate()
+    assert obj.getweakref() is None
+    obj.setweakref(space, lifeline1)
+    obj.setweakref(space, None)
+
+
 
 def test_slots():
     cls = Class()



More information about the Pypy-commit mailing list