[Cython] Safer exception handling
Robert Bradshaw
robertwb at gmail.com
Wed Sep 19 01:58:27 EDT 2018
On Tue, Sep 18, 2018, 10:12 AM Jeroen Demeyer <J.Demeyer at ugent.be> wrote:
> 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 *"?
>
We may choose an implicit default exception value.
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
>
Given that essentially every Python operation can raise exceptions, I don't
know how useful this warning would be. Unless we expect everyone to change
their code.
and this should probably be a compile-time error:
>
> cdef int foo(x):
> raise NotImplementedError
>
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> https://mail.python.org/mailman/listinfo/cython-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20180919/7c5f6c9b/attachment.html>
More information about the cython-devel
mailing list