[Cython] Generated function has invalid name when converting from python object to C struct defined in C++ namespace

Daniel Grunwald grunwald at axivion.com
Tue Mar 17 18:24:26 CET 2015


Hello,

I have Cython code like this:
     cdef extern from "cpp_library.h" namespace "CppLibrary":
         struct SomeStruct:
             int i

         void do_with_struct(SomeStruct s)

     def run():
         do_with_struct(object())

With cython 0.21.1, invalid C++ code is generated:
    struct CppLibrary::SomeStruct;
    static struct CppLibrary::SomeStruct 
__pyx_convert__from_py_CppLibrary::SomeStruct(PyObject *);

With cython master, a compiler error occurs:
     @cname("__pyx_convert__from_py_CppLibrary::SomeStruct")
     cdef SomeStruct __pyx_convert__from_py_CppLibrary::SomeStruct(obj) 
except *:
                                                      ^
     FromPyStructUtility:11:50: Expected an identifier or literal

Cython should mangle the struct name to ensure the helper function has a 
valid name.


Regards,

-- 
Daniel Grunwald
Axivion GmbH
Nobelstr. 15
70569 Stuttgart
Deutschland
Tel: +49 711 6204378-33
Fax: +49 711 6204378-99

Geschaeftsfuehrung: Stefan Bellon, Thomas Eisenbarth, Sebastian Rummler
Sitz der Gesellschaft: Stuttgart
Registergericht: Amtsgericht Stuttgart, HRB 720590



More information about the cython-devel mailing list