Armin Rigo  committed b1db1d0 Draft

The llinterp cannot convert random exception classes from random
pure Python runs. When we get one, convert it to UnknownException.

  • Participants
  • Parent commits b419aa4
  • Branches kill-someobject

Comments (0)

Files changed (3)

File pypy/jit/metainterp/test/

 import py
 from pypy.rpython.lltypesystem import lltype, llmemory, lloperation
-from pypy.rpython.llinterp import LLException
+from pypy.rpython.exceptiondata import UnknownException
 from pypy.rlib.jit import JitDriver, dont_look_inside, vref_None
 from pypy.rlib.jit import virtual_ref, virtual_ref_finish, InvalidVirtualRef
 from pypy.rlib.jit import non_virtual_ref
             return res
         py.test.raises(InvalidVirtualRef, "fn(10)")
-        py.test.raises(LLException, "self.meta_interp(fn, [10])")
+        py.test.raises(UnknownException, "self.meta_interp(fn, [10])")
     def test_call_virtualref_already_forced(self):
         myjitdriver = JitDriver(greens = [], reds = ['n', 'res'])

File pypy/rpython/

     rstackovf._StackOverflow: True,
+class UnknownException(Exception):
+    pass
 class AbstractExceptionData:
     """Public information for the code generators to help with exceptions."""
         return example
     def get_standard_ll_exc_instance_by_class(self, exceptionclass):
+        if exceptionclass not in self.standardexceptions:
+            raise UnknownException(exceptionclass)
         clsdef = self.rtyper.annotator.bookkeeper.getuniqueclassdef(
         return self.get_standard_ll_exc_instance(self.rtyper, clsdef)

File pypy/rpython/test/

 from pypy.rpython.lltypesystem.lltype import typeOf, Void, malloc, free
 from pypy.rpython.llinterp import LLInterpreter, LLException
 from pypy.rpython.rmodel import inputconst
-from pypy.rpython.annlowlevel import hlstr
+from pypy.rpython.annlowlevel import hlstr, llhelper
+from pypy.rpython.exceptiondata import UnknownException
 from pypy.translator.translator import TranslationContext, graphof
 from pypy.rpython.lltypesystem import lltype
 from pypy.annotation import model as annmodel
     res = interpret(f, [])
     assert not res
+def test_userdefined_exception():
+    class FooError(Exception):
+        pass
+    def g():
+        raise FooError
+    g_func = llhelper(lltype.Ptr(lltype.FuncType([], lltype.Void)), g)
+    def f():
+        g_func()
+    e = py.test.raises(UnknownException, interpret, f, [])
+    assert e.value.args[0] is FooError