diff options
author | Robert Bradshaw <robertwb@gmail.com> | 2018-09-20 22:41:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-20 22:41:04 +0200 |
commit | 05a2cffac1e7cb6f534664d952ba841b94a093d2 (patch) | |
tree | 12c63e68a5e6e30ed31cd9a1510a6492d8b00850 /Cython | |
parent | 871fd4ac1dc29554439543f2ea3ff2de0697eef0 (diff) | |
download | cython-05a2cffac1e7cb6f534664d952ba841b94a093d2.tar.gz |
Update ExprNodes.py
Diffstat (limited to 'Cython')
-rw-r--r-- | Cython/Compiler/ExprNodes.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 0c86afe56..a3183cc96 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -187,6 +187,8 @@ def infer_sequence_item_type(env, seq_node, index_node=None, seq_type=None): return item_types.pop() return None +# Returns a block of code to translate the exception, +# plus a boolean indicating whether to check for Python exceptions. def get_exception_handler(exception_value): if exception_value is None: return "__Pyx_CppExn2PyErr();", False @@ -201,11 +203,11 @@ def get_exception_handler(exception_value): return '%s(); if (!PyErr_Occurred()) PyErr_SetString(PyExc_RuntimeError , "Error converting c++ exception.");' % exception_value.entry.cname, False def maybe_check_py_error(code, check_py_exception, pos, nogil): - if check_py_exception: - if nogil: - code.putln(code.error_goto_if("__Pyx_ErrOccurredWithGIL()", pos)) - else: - code.putln(code.error_goto_if("PyErr_Occurred()", pos)) + if check_py_exception: + if nogil: + code.putln(code.error_goto_if("__Pyx_ErrOccurredWithGIL()", pos)) + else: + code.putln(code.error_goto_if("PyErr_Occurred()", pos)) def translate_cpp_exception(code, pos, inside, py_result, exception_value, nogil): raise_py_exception, check_py_exception = get_exception_handler(exception_value) |