[Cython] Cython generates invalid C code for some generator expressions in cdef functions

Michael Enßlin michael at ensslin.cc
Fri May 8 14:37:23 CEST 2015


Take the following example:


$ cat t2.pyx
cdef void read_callback():
    foo = b"asdf"
    bar = (c for c in foo)



$ cython t2.pyx



$ gcc -I/usr/include/python3.4m t2.c
t2.c: In function ‘__pyx_f_2t2_read_callback’:
t2.c:778:12: error: ‘None’ undeclared (first use in this function)
     return None;
            ^
t2.c:778:12: note: each undeclared identifier is reported only once for
each function it appears in
t2.c:778:5: warning: ‘return’ with a value, in function returning void
     return None;
     ^


Note that the error does not occur for

bar = (c for c in b"asdf")

or

bar = [c for c in b"asdf"]


 ~ mic_e

-------------- 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/20150508/7a108001/attachment.sig>


More information about the cython-devel mailing list