[pypy-svn] r20491 - in pypy/branch/somepbc-refactoring/pypy/rpython: lltypesystem test

arigo at codespeak.net arigo at codespeak.net
Thu Dec 1 13:15:53 CET 2005


Author: arigo
Date: Thu Dec  1 13:15:52 2005
New Revision: 20491

Modified:
   pypy/branch/somepbc-refactoring/pypy/rpython/lltypesystem/rclass.py
   pypy/branch/somepbc-refactoring/pypy/rpython/test/test_rclass.py
Log:
(mwh, pedronis, arigo)

* Made the test actually test something (magic flow space again)
* Fix for the test: when a class attribute is read
  directly from a family of classes, put it in the
  vtable for exactly these classes (not subclasses).



Modified: pypy/branch/somepbc-refactoring/pypy/rpython/lltypesystem/rclass.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/lltypesystem/rclass.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/lltypesystem/rclass.py	Thu Dec  1 13:15:52 2005
@@ -200,8 +200,10 @@
                 value = rsubcls.classdef.classdesc.read_attribute(fldname, None)
                 if value is not None:
                     assign(mangled_name, value)
-            # extra PBC attributes  # xxx couldn't they be implemented as regular readonyla attrs?
+            # extra PBC attributes
             for (access_set, attr), (mangled_name, r) in self.pbcfields.items():
+                if rsubcls.classdef.classdesc not in access_set.descs:
+                    continue   # only for the classes in the same pbc access set
                 if r.lowleveltype is Void:
                     continue
                 attrvalue = rsubcls.classdef.classdesc.read_attribute(attr, None)

Modified: pypy/branch/somepbc-refactoring/pypy/rpython/test/test_rclass.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/test/test_rclass.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/test/test_rclass.py	Thu Dec  1 13:15:52 2005
@@ -342,12 +342,13 @@
     class C(B):
         def meth(self):
             return self.value - 1
-    def f(i):
+    def pick_class(i):
         if i > 0:
-            cls = A
+            return A
         else:
-            cls = C
-        meth = cls.meth
+            return C
+    def f(i):
+        meth = pick_class(i).meth
         x = C()
         x.value = 12
         return meth(x)   # calls A.meth or C.meth, completely ignores B.meth



More information about the Pypy-commit mailing list