Skip to content

[BUG] Bad C code generated for Python's complex type #3949

@gmc444-b

Description

@gmc444-b

Describe the bug

With the Cython code and the setup.py below, C compilation fails with errors like

ct.c:1409:49: error: unknown type name '__pyx_t_double_complex'
static PyObject *__pyx_f_2ct_func(CYTHON_UNUSED __pyx_t_double_complex __pyx_v_arg) {

To Reproduce
Code to reproduce the behaviour:

cdef func(arg: complex):
    pass

The setup.py:

from setuptools import Extension
from setuptools import setup

from Cython.Build import cythonize

setup(
    name="ct",
    ext_modules=cythonize(
        Extension("ct", sources=["ct.pyx"]),
        language_level=3,
    ),
)

I searched through the issues and documentation, and haven't been able to find anything specific to this problem.

Expected behavior

Since complex is a built-in type, I'd expect that either the correct type name be generated, or if this is the correct type name, that it be properly defined before being referenced.

Environment (please complete the following information):

  • OS: I've reproduced this on MacOS 10.15.7 and Linux 2.6.32
  • Python versions 3.8 and 3.9
  • Cython versions 0.29.21 and 3.0a6

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions