[pypy-svn] r37819 - in pypy/branch/jit-virtual-world/pypy/rpython: . ootypesystem test

arigo at codespeak.net arigo at codespeak.net
Fri Feb 2 20:35:32 CET 2007


Author: arigo
Date: Fri Feb  2 20:35:23 2007
New Revision: 37819

Modified:
   pypy/branch/jit-virtual-world/pypy/rpython/ootypesystem/rpbc.py
   pypy/branch/jit-virtual-world/pypy/rpython/rpbc.py
   pypy/branch/jit-virtual-world/pypy/rpython/test/test_rpbc.py
Log:
A strange case of method call that showed up in the JIT.


Modified: pypy/branch/jit-virtual-world/pypy/rpython/ootypesystem/rpbc.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/rpython/ootypesystem/rpbc.py	(original)
+++ pypy/branch/jit-virtual-world/pypy/rpython/ootypesystem/rpbc.py	Fri Feb  2 20:35:23 2007
@@ -1,4 +1,4 @@
-from pypy.rpython.rmodel import CanBeNull, Repr, inputconst
+from pypy.rpython.rmodel import CanBeNull, Repr, inputconst, impossible_repr
 from pypy.rpython.rpbc import AbstractClassesPBCRepr, AbstractMethodsPBCRepr, \
         AbstractMultipleFrozenPBCRepr, MethodOfFrozenPBCRepr, \
         AbstractFunctionsPBCRepr, AbstractMultipleUnrelatedFrozenPBCRepr, \
@@ -132,7 +132,10 @@
         assert meth is not None, 'Missing method %s in class %s'\
                % (derived_mangled, self.r_im_self.lowleveltype)
         v = hop.genop("oosend", [cname]+vlist, resulttype=rresult)
-        return hop.llops.convertvar(v, rresult, hop.r_result)
+        if hop.r_result is impossible_repr:
+            return None      # see test_always_raising_methods
+        else:
+            return hop.llops.convertvar(v, rresult, hop.r_result)
 
     def _get_shape_index_callfamily(self, opname, s_pbc, args_s):
         bk = self.rtyper.annotator.bookkeeper

Modified: pypy/branch/jit-virtual-world/pypy/rpython/rpbc.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/rpython/rpbc.py	(original)
+++ pypy/branch/jit-virtual-world/pypy/rpython/rpbc.py	Fri Feb  2 20:35:23 2007
@@ -8,7 +8,7 @@
      typeOf, Void, Bool, nullptr, frozendict, Ptr, Struct, malloc
 from pypy.rpython.error import TyperError
 from pypy.rpython.rmodel import Repr, inputconst, HalfConcreteWrapper, CanBeNull, \
-        mangle, inputdesc, warning
+        mangle, inputdesc, warning, impossible_repr
 from pypy.rpython import rclass
 from pypy.rpython import robject
 
@@ -330,7 +330,10 @@
         else:
             vlist.append(hop.inputconst(Void, row_of_graphs.values()))
             v = hop.genop('indirect_call', vlist, resulttype = rresult)
-        return hop.llops.convertvar(v, rresult, hop.r_result)
+        if hop.r_result is impossible_repr:
+            return None      # see test_always_raising_methods
+        else:
+            return hop.llops.convertvar(v, rresult, hop.r_result)
 
 class __extend__(pairtype(AbstractFunctionsPBCRepr, AbstractFunctionsPBCRepr)):
         def convert_from_to((r_fpbc1, r_fpbc2), v, llops):

Modified: pypy/branch/jit-virtual-world/pypy/rpython/test/test_rpbc.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/rpython/test/test_rpbc.py	(original)
+++ pypy/branch/jit-virtual-world/pypy/rpython/test/test_rpbc.py	Fri Feb  2 20:35:23 2007
@@ -1542,6 +1542,28 @@
         assert self.ll_to_string(item0) == "hello"
         assert item1 == 623
 
+    def test_always_raising_methods(self):
+        class Base:
+            def m(self):
+                raise NotImplementedError
+        class A(Base):
+            def m(self):
+                return 42
+        class B(Base):
+            pass
+        def f(n):
+            if n > 3:
+                o = A()
+            else:
+                o = B()
+            try:
+                o.m()
+            except NotImplementedError:
+                pass
+            return B().m()
+
+        self.interpret_raises(NotImplementedError, f, [7])
+
 
 class TestLLtype(BaseTestRPBC, LLRtypeMixin):
     pass



More information about the Pypy-commit mailing list