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

cannot use some templates inside "with nogil" #1402

Open
robertwb opened this issue Apr 27, 2015 · 0 comments
Open

cannot use some templates inside "with nogil" #1402

robertwb opened this issue Apr 27, 2015 · 0 comments

Comments

@robertwb
Copy link
Contributor

robertwb commented Apr 27, 2015

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
* cside.cpp:

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

template void fun(int *arg1, int *arg2);
* cside.cppcythonside1.pyx:

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

def test():
  cdef int arg
  fun[&arg)
* cside.cppcythonside2.pyx:

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

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

1 participant