robertwb / issues-import-test

0 stars 0 forks source link

cannot use some templates inside "with nogil" #1000

Open robertwb opened 9 years ago

robertwb commented 9 years ago

If a C++ templated function has more than one template argument, it cannot be used inside a "with nogil:" block, at least in 0.21.1, the version in debian sid. I have attached a MWE:

cythonside1.pyx does not use nogil, compiles and runs fine.

cythonside2.pyx uses nogil, fails to compile with the following error:

Error compiling Cython file:

...

def test(): cdef int arg with nogil: fun[&arg)

^

cythonside2.pyx:9:7: Constructing Python tuple not allowed without gil

template<typename A, typename B> void fun(A arg1, B arg2) { printf("In fun\n"); }

template void fun(int arg1, int arg2);

cdef extern from "cside.hpp" nogil: void fun[A,B](int,int](&arg,)(A arg1, B arg2)

def test(): cdef int arg fun[&arg)

cdef extern from "cside.hpp" nogil: void fun[A,B](int,int](&arg,)(A arg1, B arg2)

def test(): cdef int arg with nogil: fun[int,int](&arg, &arg)

At 2015-04-27T19:07:27Z josedavid added attachment cythonbug.zip

Migrated from http://trac.cython.org/ticket/848