From 0f2a0d38b60e10e401aa1435801b2b8975083c7b Mon Sep 17 00:00:00 2001 From: da-woods Date: Sun, 5 Nov 2023 09:45:07 +0000 Subject: [PATCH] Fix cpdef functions and cimport_from_pyx (#5796) Fixes #5795 --- Cython/Compiler/FusedNode.py | 5 +++-- tests/run/cimport_from_pyx.srctree | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/FusedNode.py b/Cython/Compiler/FusedNode.py index f59f5b0a885..31793a404a8 100644 --- a/Cython/Compiler/FusedNode.py +++ b/Cython/Compiler/FusedNode.py @@ -959,8 +959,9 @@ def generate_function_definitions(self, env, code): from . import Options for stat in self.stats: - from_pyx = Options.cimport_from_pyx and not stat.entry.visibility == 'extern' - if isinstance(stat, FuncDefNode) and (stat.entry.used or from_pyx): + if isinstance(stat, FuncDefNode) and ( + stat.entry.used or + (Options.cimport_from_pyx and not stat.entry.visibility == 'extern')): code.mark_pos(stat.pos) stat.generate_function_definitions(env, code) diff --git a/tests/run/cimport_from_pyx.srctree b/tests/run/cimport_from_pyx.srctree index 4a76c7587e5..5f82d835ca3 100644 --- a/tests/run/cimport_from_pyx.srctree +++ b/tests/run/cimport_from_pyx.srctree @@ -96,5 +96,8 @@ cdef fused_checker(fused_type i): else: return False +cpdef fused_cpdef(fused_type i): + return not fused_checker(i) + def test(): - return fused_checker(0) + return fused_checker(0) and fused_cpdef(1.0)