[pypy-svn] r14015 - pypy/dist/pypy/rpython

arigo at codespeak.net arigo at codespeak.net
Wed Jun 29 21:09:58 CEST 2005


Author: arigo
Date: Wed Jun 29 21:09:56 2005
New Revision: 14015

Modified:
   pypy/dist/pypy/rpython/rclass.py
   pypy/dist/pypy/rpython/rpbc.py
   pypy/dist/pypy/rpython/rtyper.py
Log:
- Fix for already-checked-in failing test (oups) test_method_both_A_and_B.

- Nicer error messages from low-level type mismatches in the rtyper.



Modified: pypy/dist/pypy/rpython/rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/rclass.py	(original)
+++ pypy/dist/pypy/rpython/rclass.py	Wed Jun 29 21:09:56 2005
@@ -484,7 +484,8 @@
         elif attr in self.rclass.allmethods:
             # special case for methods: represented as their 'self' only
             # (see MethodsPBCRepr)
-            return vinst
+            return hop.r_result.get_method_from_instance(self, vinst,
+                                                         hop.llops)
         else:
             vcls = self.getfield(vinst, '__class__', hop.llops)
             return self.rclass.getclsfield(vcls, attr, hop.llops)

Modified: pypy/dist/pypy/rpython/rpbc.py
==============================================================================
--- pypy/dist/pypy/rpython/rpbc.py	(original)
+++ pypy/dist/pypy/rpython/rpbc.py	Wed Jun 29 21:09:56 2005
@@ -390,6 +390,11 @@
             raise TyperError("not a bound method: %r" % method)
         return self.r_im_self.convert_const(method.im_self)
 
+    def get_method_from_instance(self, r_inst, v_inst, llops):
+        # The 'self' might have to be cast to a parent class
+        # (as shown for example in test_rclass/test_method_both_A_and_B)
+        return llops.convertvar(v_inst, r_inst, self.r_im_self)
+
     def rtype_simple_call(self, hop):
         r_class = self.r_im_self.rclass
         mangled_name, r_func = r_class.clsfields[self.methodname]

Modified: pypy/dist/pypy/rpython/rtyper.py
==============================================================================
--- pypy/dist/pypy/rpython/rtyper.py	(original)
+++ pypy/dist/pypy/rpython/rtyper.py	Wed Jun 29 21:09:56 2005
@@ -273,11 +273,11 @@
             op.result.concretetype = hop.r_result.lowleveltype
             if op.result.concretetype != resulttype:
                 raise TyperError("inconsistent type for the result of '%s':\n"
-                                 "annotator says  %s,\n"
-                                 "whose lltype is %r\n"
-                                 "but rtype* says %r" % (
+                                 "annotator says %s,\n"
+                                 "whose repr is %r\n"
+                                 "but rtype_%s returned %r" % (
                     op.opname, hop.s_result,
-                    op.result.concretetype, resulttype))
+                    hop.r_result, op.opname, resulttype))
             # figure out if the resultvar is a completely fresh Variable or not
             if (isinstance(resultvar, Variable) and
                 resultvar not in self.annotator.bindings and
@@ -473,7 +473,7 @@
         self.rtyper = rtyper
 
     def convertvar(self, v, r_from, r_to):
-        assert isinstance(v, Variable)
+        assert isinstance(v, (Variable, Constant))
         if r_from != r_to:
             v = pair(r_from, r_to).convert_from_to(v, self)
             if v is NotImplemented:



More information about the Pypy-commit mailing list