summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2020-06-04 11:21:26 +0200
committerStefan Behnel <stefan_ml@behnel.de>2020-06-04 11:24:00 +0200
commit19553a9c53b08685cf9b092227702966145f1669 (patch)
tree040ecaf33d7abcf9e1bd49bd2b0842305e522fb5
parentcefaa6522d60c4daecf01083641b874235f07bb3 (diff)
downloadcython-gh3625_returns_exc.tar.gz
Check for exceptions also when @returns() is used, not only for "->" return type annotations.gh3625_returns_exc
See https://github.com/cython/cython/issues/3625#issuecomment-631931675
-rw-r--r--Cython/Compiler/ParseTreeTransforms.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py
index acdbd0c0d..fad947c32 100644
--- a/Cython/Compiler/ParseTreeTransforms.py
+++ b/Cython/Compiler/ParseTreeTransforms.py
@@ -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,