diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index ce3399a20f1473539de72dc199b6320e16aea77b..ac28d03e3de115d9be1ae2d1602bb1ff2f2f8f47 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -7812,6 +7812,14 @@ class PyCFunctionNode(ExprNode, ModuleNameMixin): if not arg.annotation.type.is_pyobject: arg.annotation = arg.annotation.coerce_to_pyobject(env) annotations.append((arg.pos, arg.name, arg.annotation)) + + for arg in (self.def_node.star_arg, self.def_node.starstar_arg): + if arg and arg.annotation: + arg.annotation = arg.annotation.analyse_types(env) + if not arg.annotation.type.is_pyobject: + arg.annotation = arg.annotation.coerce_to_pyobject(env) + annotations.append((arg.pos, arg.name, arg.annotation)) + if self.def_node.return_type_annotation: annotations.append((self.def_node.return_type_annotation.pos, StringEncoding.EncodedString("return"), diff --git a/tests/run/cython3.pyx b/tests/run/cython3.pyx index 3d0f8e369269a14bc9004ffdeb841b7d471739f1..378cbc03d636bfb6e4ef4714e2eae11a508004cf 100644 --- a/tests/run/cython3.pyx +++ b/tests/run/cython3.pyx @@ -1,4 +1,4 @@ -# cython: language_level=3 +# cython: language_level=3, binding=True # mode: run # tag: generators, python3, exceptions @@ -437,11 +437,24 @@ def int_literals(): print(cython.typeof(1UL)) print(cython.typeof(10000000000000UL)) -def annotation_syntax(a : "test new test", b : "other" = 2) -> "ret": +def annotation_syntax(a: "test new test", b : "other" = 2, *args: "ARGS", **kwargs: "KWARGS") -> "ret": """ >>> annotation_syntax(1) 3 >>> annotation_syntax(1,3) 4 + + >>> len(annotation_syntax.__annotations__) + 5 + >>> print(annotation_syntax.__annotations__['a']) + test new test + >>> print(annotation_syntax.__annotations__['b']) + other + >>> print(annotation_syntax.__annotations__['args']) + ARGS + >>> print(annotation_syntax.__annotations__['kwargs']) + KWARGS + >>> print(annotation_syntax.__annotations__['return']) + ret """ return a+b