From 19553a9c53b08685cf9b092227702966145f1669 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 4 Jun 2020 11:21:26 +0200 Subject: Check for exceptions also when @returns() is used, not only for "->" return type annotations. See https://github.com/cython/cython/issues/3625#issuecomment-631931675 --- Cython/Compiler/ParseTreeTransforms.py | 4 ++-- 1 file 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, -- cgit v1.2.1