Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gmc444-b opened this issue Dec 18, 2020 · 3 comments · Fixed by #3950
Closed

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

gmc444-b opened this issue Dec 18, 2020 · 3 comments · Fixed by #3950

Comments

@gmc444-b
Copy link

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.

@robertwb
Copy link
Contributor

Does it help if you use this argument?

@gmc444-b
Copy link
Author

Does it help if you use this argument?

I'm not sure what you're referring to.

da-woods added a commit to da-woods/cython that referenced this issue Dec 18, 2020
Generating utility-code for complex types is special-cased, but
it wasn't when they were generated in annotations.

Fixes cython#3949
@da-woods
Copy link
Contributor

I think this should work if you don't use annotations to type it (e.g. cdef f(complex x):). I've got a patch for this (and a similar bug) though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants