4 ms·
Whilst reading that thread, I stumbled accross: "goto fail" is a well-known error handling mechanism in open source software, widely reputed for its robus
by Nanzikambe 13y ago
Whilst reading that thread, I stumbled accross:
"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.
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.
https://mail.python.org/pipermail/python-ideas/2014-March/026581.html https://mail.python.org/pipermail/python-ideas/2014-March/02...
- mercurial 13y agoPicking on C's error handling mechanism is like picking on its non-existent standard library: it's been done to death.
- kingkilr 13y agoPython already comes with the logical conclusion of goto-fail out of the box. There's no need to add a new special feature for it. (There is absolutely no certificate store checking for certs by default, nor is there any hostname checking, or any of the myriad of other checks one might expect a reasonable TLS implementation to perform. Use the requests module.)