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

arigo at codespeak.net arigo at codespeak.net
Mon Dec 10 16:14:06 CET 2007


Author: arigo
Date: Mon Dec 10 16:14:05 2007
New Revision: 49601

Modified:
   pypy/dist/pypy/objspace/std/test/test_shadowtracking.py
   pypy/dist/pypy/objspace/std/typetype.py
Log:
Test and fix for __bases__ assignment versus the method cache.


Modified: pypy/dist/pypy/objspace/std/test/test_shadowtracking.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_shadowtracking.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_shadowtracking.py	Mon Dec 10 16:14:05 2007
@@ -211,3 +211,22 @@
         assert append_counter[0] >= 5 * len(names)
         for name, count in zip(names, names_counters):
             assert count[0] >= 5
+
+    def test_mutating_bases(self):
+        class C(object):
+            pass
+        class C2(object):
+            foo = 5
+        class D(C):
+            pass
+        class E(D):
+            pass
+        d = D()
+        e = E()
+        D.__bases__ = (C2,)
+        assert e.foo == 5
+
+        class F(object):
+            foo = 3
+        D.__bases__ = (C, F)
+        assert e.foo == 3

Modified: pypy/dist/pypy/objspace/std/typetype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/typetype.py	(original)
+++ pypy/dist/pypy/objspace/std/typetype.py	Mon Dec 10 16:14:05 2007
@@ -172,9 +172,9 @@
         raise OperationError(space.w_TypeError,
                              space.wrap("__bases__ assignment: '%s' object layout differs from '%s'" %
                                         (w_type.getname(space, '?'), new_base.getname(space, '?'))))
-    if space.config.objspace.std.withtypeversion:
-        # it does not make sense to cache this type, it changes bases
-        w_type.version_tag = None
+
+    # invalidate the version_tag of all the current subclasses
+    w_type.mutated()
 
     saved_bases = w_type.bases_w
     saved_base = w_type.w_bestbase



More information about the Pypy-commit mailing list