[pypy-commit] pypy cpyext-gc-support: Remove "except OperationError: raise" from the final RPython code

arigo noreply at buildbot.pypy.org
Sat Oct 24 07:35:50 EDT 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: cpyext-gc-support
Changeset: r80421:7bd9cece7986
Date: 2015-10-24 13:36 +0200
http://bitbucket.org/pypy/pypy/changeset/7bd9cece7986/

Log:	Remove "except OperationError: raise" from the final RPython code

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -330,23 +330,27 @@
                         # arg is not declared as PyObject, no magic
                         arg = input_arg
                     newargs += (arg, )
-                try:
+                if not catch_exception:
                     try:
                         res = func(space, *newargs)
                     finally:
                         keepalive_until_here(*keepalives)
-                except OperationError, e:
-                    if not catch_exception:
-                        raise
-                    if not hasattr(api_function, "error_value"):
-                        raise
-                    state = space.fromcache(State)
-                    state.set_exception(e)
-                    if is_PyObject(restype):
-                        return None
-                    else:
-                        return api_function.error_value
-                if not we_are_translated():
+                else:
+                    # non-rpython variant
+                    assert not we_are_translated()
+                    try:
+                        res = func(space, *newargs)
+                    except OperationError, e:
+                        if not hasattr(api_function, "error_value"):
+                            raise
+                        state = space.fromcache(State)
+                        state.set_exception(e)
+                        if is_PyObject(restype):
+                            return None
+                        else:
+                            return api_function.error_value
+                    finally:
+                        keepalive_until_here(*keepalives)
                     got_integer = isinstance(res, (int, long, float))
                     assert got_integer == expect_integer,'got %r not integer' % res
                 return res


More information about the pypy-commit mailing list