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

C API returns PyCapsule with incorrect function signature #2027

Closed
ashwinvis opened this issue Nov 27, 2017 · 1 comment
Closed

C API returns PyCapsule with incorrect function signature #2027

ashwinvis opened this issue Nov 27, 2017 · 1 comment

Comments

@ashwinvis
Copy link

What does not work

# add_int.pyx
cdef api add(int x, int y):
    cdef int r;
    r = x + y;
    return r

check:

>>> import add_int
>>> add_int.__pyx_capi__['add']
<capsule object "PyObject *(int, int)" at 0x7f731cfdd540>

What works

However if I use cythonize an external C code which does the same thing, it gives me a PyCapsule with proper signature. (see link below for the code)

>>> import cy_add_int
>>> cy_add_int.__pyx_capi__['cy_add']
<capsule object "int (int, int)" at 0x7f7169dfba50>

I have uploaded the source files for the above cases with Makefiles if anybody wants to check. Just run make build.

https://github.com/ashwinvis/cython_capi/tree/master/cython_issue

This is also related to serge-sans-paille/pythran/issues/743 where Pythran is adding the possibility to pass Cython functions as arguments through PyCapsules. cc:@serge-sans-paille

@scoder
Copy link
Contributor

scoder commented Nov 27, 2017

The signature is correct. The return type is object in the first case. See, for example:
http://docs.cython.org/en/latest/src/reference/language_basics.html#parameters

@scoder scoder closed this as completed Nov 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants