[Cython] cython --cplus --embed generates invalid code

Michael Enßlin michael at ensslin.cc
Sun Nov 30 16:14:08 CET 2014


Hi,

on my system, --embed does not work with --cplus.

How to reproduce: Any valid pyx file works:

$ rm -f test.pyx; touch test.pyx
$ cython --embed --cplus test.pyx
$ g++ -c test.cpp -I/usr/include/python3.4m
test.cpp: In function ‘wchar_t* __Pyx_char2wchar(char*)’:
test.cpp:945:41: error: invalid conversion from ‘void*’ to ‘wchar_t*’
[-fpermissive]
     res = malloc(argsize*sizeof(wchar_t));
$ clang++ -c test.cpp -I/usr/include/python3.4m
test.cpp:945:9: error: assigning to 'wchar_t *' from incompatible type
'void *'
    res = malloc(argsize*sizeof(wchar_t));


The issue can easily be fixed by manually casting the malloc result to
(wchar_t *).
In C it is not recommended to cast the malloc result, while in C++ it is
required (and malloc is discouraged).

System info:

$ cython --version
Cython version 0.21.1
$ g++ --version
g++ (Debian 4.9.2-2) 4.9.2
$ python3 --version
Python 3.4.2
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux unstable (sid)
Release:	unstable
Codename:	sid

~ Michael

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20141130/08a0bb0c/attachment.sig>


More information about the cython-devel mailing list