[Cython] Safer exception handling

Jeroen Demeyer J.Demeyer at UGent.be
Tue Sep 18 04:12:28 EDT 2018


On 2018-09-17 15:44, Robert Bradshaw wrote:
> One of the pain points in Cython is that one must explicitly annotate
> non-object returning functions with except clauses. Would it be worth
> trying to change the default here, making exception-suppressing opt-in
> rather than opt-out?

Just to clarify things: are you proposing that the default would be 
"except *"?

An alternative would be to give *warnings* for functions where 
exceptions could occur but could not be propagated. For example, this 
function is totally fine:

cdef int foo(int x):
     return x

but this function would give a warning:

cdef int foo(x):
     return x   # implicit conversion Python -> int

and this should probably be a compile-time error:

cdef int foo(x):
     raise NotImplementedError



More information about the cython-devel mailing list