Commit 95bad952 authored by scoder's avatar scoder Committed by GitHub

Check for exceptions also when @returns() is used, not only for "->" return...

Check for exceptions also when @returns() is used, not only for "->" return type annotations. (GH-3664)

When you use Python type annotations, it would be weird if you lost Python exception propagation semantics along the way, just by compiling the code. So the default behaviour is "except? -1" here for C integer types.

Arguably, this would also be a better default for the decorator case.

See https://github.com/cython/cython/issues/3625#issuecomment-631931675
parent 9923a5cb
......@@ -2445,8 +2445,8 @@ class AdjustDefByDirectives(CythonTransform, SkipDeclarations):
if return_type_node is not None and except_val is None:
except_val = (None, True) # except *
elif except_val is None:
# backward compatible default: no exception check
except_val = (None, False)
# backward compatible default: no exception check, unless there's also a "@returns" declaration
except_val = (None, True if return_type_node else False)
if 'ccall' in self.directives:
node = node.as_cfunction(
overridable=True, modifiers=modifiers, nogil=nogil,
......
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