[pypy-commit] pypy hpy: introduce a new decorator @llhelper_can_raise and use it to fix test_exception

antocuni pypy.commits at gmail.com
Mon Nov 18 17:35:57 EST 2019


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: hpy
Changeset: r98120:87553600e78a
Date: 2019-11-18 23:24 +0100
http://bitbucket.org/pypy/pypy/changeset/87553600e78a/

Log:	introduce a new decorator @llhelper_can_raise and use it to fix
	test_exception

diff --git a/pypy/module/hpy_universal/interp_hpy.py b/pypy/module/hpy_universal/interp_hpy.py
--- a/pypy/module/hpy_universal/interp_hpy.py
+++ b/pypy/module/hpy_universal/interp_hpy.py
@@ -1,7 +1,7 @@
 from rpython.rtyper.annlowlevel import llhelper
 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.rlib.rdynload import dlopen, dlsym, DLOpenError
-from rpython.rlib.objectmodel import specialize
+from rpython.rlib.objectmodel import specialize, llhelper_can_raise
 from rpython.rlib import rutf8
 
 from pypy.interpreter.gateway import unwrap_spec
@@ -21,6 +21,7 @@
         ll_functype = lltype.Ptr(lltype.FuncType(argtypes, restype))
         @specialize.memo()
         def make_wrapper(space):
+            @llhelper_can_raise
             def wrapper(*args):
                 return fn(space, *args)
             return wrapper
diff --git a/rpython/rlib/objectmodel.py b/rpython/rlib/objectmodel.py
--- a/rpython/rlib/objectmodel.py
+++ b/rpython/rlib/objectmodel.py
@@ -226,6 +226,13 @@
     func._not_rpython_ = True
     return func
 
+def llhelper_can_raise(func):
+    """
+    Instruct ll2ctypes that this llhelper can raise RPython exceptions, which
+    should be propagated.
+    """
+    func._llhelper_can_raise_ = True
+    return func
 
 # ____________________________________________________________
 


More information about the pypy-commit mailing list