Commit 05a2cffa authored by Robert Bradshaw's avatar Robert Bradshaw Committed by GitHub

Update ExprNodes.py

parent 871fd4ac
...@@ -187,6 +187,8 @@ def infer_sequence_item_type(env, seq_node, index_node=None, seq_type=None): ...@@ -187,6 +187,8 @@ def infer_sequence_item_type(env, seq_node, index_node=None, seq_type=None):
return item_types.pop() return item_types.pop()
return None 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): def get_exception_handler(exception_value):
if exception_value is None: if exception_value is None:
return "__Pyx_CppExn2PyErr();", False return "__Pyx_CppExn2PyErr();", False
...@@ -201,11 +203,11 @@ def get_exception_handler(exception_value): ...@@ -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 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): def maybe_check_py_error(code, check_py_exception, pos, nogil):
if check_py_exception: if check_py_exception:
if nogil: if nogil:
code.putln(code.error_goto_if("__Pyx_ErrOccurredWithGIL()", pos)) code.putln(code.error_goto_if("__Pyx_ErrOccurredWithGIL()", pos))
else: else:
code.putln(code.error_goto_if("PyErr_Occurred()", pos)) code.putln(code.error_goto_if("PyErr_Occurred()", pos))
def translate_cpp_exception(code, pos, inside, py_result, exception_value, nogil): def translate_cpp_exception(code, pos, inside, py_result, exception_value, nogil):
raise_py_exception, check_py_exception = get_exception_handler(exception_value) raise_py_exception, check_py_exception = get_exception_handler(exception_value)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment