[Cython] Safer exception handling

Robert Bradshaw robertwb at gmail.com
Thu Sep 20 02:17:13 EDT 2018


On Wed, Sep 19, 2018, 5:04 PM Stefan Behnel <stefan_ml at behnel.de> wrote:

> Robert Bradshaw schrieb am 17.09.2018 um 15:44:
> > 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?
> >
> > There are a couple of open questions, e.g.
> >   * What would the syntax be?
> >   * What about extern functions?
> >   * What would the performance impact be? Could it be mitigated?
>
> One more point: what about nogil functions? They can, in theory, raise
> exceptions, but they almost never do in practice.
>

I think feels like it should be orthogonal, I wonder what the overhead of
this check really is in practice...

Given that the default for return type annotations is exception propagation
> (i.e. Python semantics) now, mixing that into a nogil function means that
> the caller would almost always check for exceptions needlessly. And we do
> not currently have a way to say "no exception return value" to get rid of
> that check. That's something we'd need, especially if we change the
> default.
>

Yeah, that's what I meant about the syntax question.


> Stefan
> _______________________________________________
> 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/20180920/ca06156b/attachment.html>


More information about the cython-devel mailing list