Lisandro Dalcin, 01.05.2013 09:14:
> See the example below, the last hunk fails with Cython 0.19. It seems
> Cython is confusing attribute access with constness.
> 
> 
> CYTHON=cython
> 
> echo 'cdef import from *:' > defs.pxd
> echo '    enum:SIZE'      >> defs.pxd
> 
> echo 'from defs cimport *'   > code1.pyx
> echo 'cdef char buf[SIZE]'  >> code1.pyx
> $CYTHON code1.pyx
> 
> echo 'cimport defs'              > code2.pyx
> echo 'cdef char buf[defs.SIZE]' >> code2.pyx
> $CYTHON code2.pyx

With the above setup, I get Cython compile errors in 0.19:

Error compiling Cython file:
------------------------------------------------------------
...
cimport defs
cdef char buf[defs.SIZE]
                 ^
------------------------------------------------------------
code2.pyx:2:18: Not allowed in a constant expression

Interesting enough, this happens during declaration analysis, not during
type analysis. Looks like that's needed because the array size is part of
the declaration.

ISTM that the implementation of analyse_const_expression() is wrong. It
doesn't care about the result of analyse_types().

Stefan

_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel

Reply via email to