[Python-ideas] Add "goto fail" to Python?

Nick Coghlan ncoghlan at gmail.com
Thu Mar 6 11:11:21 CET 2014


On 6 Mar 2014 13:55, "Sturla Molden" <sturla.molden at gmail.com> wrote:
>
> "goto fail" is a well-known error handling mechanism in open source
software, widely reputed for its robusteness:
>
>
http://opensource.apple.com/source/Security/Security-55471/libsecurity_ssl/lib/sslKeyExchange.c
>
>
https://www.gitorious.org/gnutls/gnutls/source/6aa26f78150ccbdf0aec1878a41c17c41d358a3b:lib/x509/verify.c
>
> I believe Python needs to add support for this superior paradigm.

Unfortunately, we can't throw stones about those, since we currently have
hostname matching off by default and expect developers to turn it on.

That needs to change, but there are a few thorny practical issues to sort
out in order to get there (Christian Heimes has been working through
several of them).

Cheers,
Nick.

>
> It would involve a new keyword "fail" and some means of goto'ing to it. I
suggest "raise to fail":
>
> if (some_error):
>    raise to fail
>
> fail:
>    <error handling code>
>
> Unless there are many objections, this fantastic idea might be submitted
in a (short) PEP somewhere around the beginning of next month.
>
> There is some obvious overlap with the rejected "goto PEP" (PEP 3163) and
the Python 2.3 goto module. However, the superiority of goto fail as error
generation and error handling paradigm has since then been thoroughly
proven.
>
> http://legacy.python.org/dev/peps/pep-3136/
> http://entrian.com/goto/download.html
>
>
> Regards,
> Sturla Molden
>
>
>
>
>
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140306/a6fbc1f8/attachment.html>


More information about the Python-ideas mailing list