[Cython] Misleading error message when assigning function pointers with differing except* declarations

Stefan Behnel stefan_ml at behnel.de
Thu May 21 21:29:15 CEST 2015


Michael Enßlin schrieb am 07.05.2015 um 15:13:
> consider the following example:
> 
> $ cat demo.pyx
> cdef void (*foo)()
> 
> cdef void bar() except*:
>     pass
> 
> foo = bar
> 
> 
> 
> $ cython demo.pyx
> 
> Error compiling Cython file:
> ------------------------------------------------------------
> ...
> cdef void (*foo)()
> 
> cdef void bar() except*:
>     pass
> 
> foo = bar
>         ^
> ------------------------------------------------------------
> 
> demo.pyx:6:9: Cannot assign type 'void (void)' to 'void (*)(void)'
> 
> this is all expected behavior, but the error message is entirely
> misleading; it should be something like
> 
> demo.pyx:6:9: Function pointers have incompatible 'except *' declarations.

Thanks for the report. I think displaying "except *" as part of the
function type would make this clear enough, i.e. you'd get

    Cannot assign type 'void (void) except *' to 'void (*)(void)'

https://github.com/cython/cython/commit/937f83149eaf979850faa25f62857e29726c11a6

Stefan



More information about the cython-devel mailing list