Lisandro Dalcin wrote:
> After hg update'd cython-devel, and now the code below generates a
> compiler error:
> 
> cdef extern from "compat.h":
>     pass
>    ^
> ------------------------------------------------------------
> 
> /u/dalcinl/Devel/petsc4py-dev/src/PETSc/PETSc.pyx:67:4: Expected an
> identifier, found 'pass'

Hmm, looks like I've broken that.

http://hg.cython.org/cython-devel/rev/6515c3757571

The grammar of the cdef statement is pretty bizarre. It previously allowed
you to write "cdef pass" for a "pass" statement, for example.

It looks like the change in p_c_simple_base_type() is responsible here,
although I suspect the real problem is in p_statement(). It parses a
statement differently when the cdef_flag is set, also externally, i.e. when
the statement itself is not preceded by a "cdef". This makes

        cdef extern from "compat.h":
            pass

and

        cdef extern from "compat.h":
            int a

possible, but also allows interpreting "pass" as type name. That shouldn't
be allowed.


> IIRC, that is a documented way to force inclusion of C headers... What
> this intentional? BTW... "tests/broken/cdefexternempty.pyx" has a
> tescase for this... For some reason, it never got promoted as a
> working test...

Yes, some of those are just there because they didn't make sense in the
test runner, e.g. because the resulting C code wouldn't compile, or the
module wouldn't load into CPython. Greg's test suite doesn't actually
C-compile stuff, but only checks that the C code comes out as expected.
That might work for a one-person-project, but definitely not for Cython.

Could you try to come up with a compilable test case for this? I pushed an
untested fix.

http://hg.cython.org/cython-devel/rev/e6f5fc96fb42

Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to