[Python-ideas] Proposal: Abolition of bare except clauses

Alexander Walters tritium-list at sdamon.com
Sat Apr 11 15:11:56 CEST 2015


On 4/11/2015 08:25, Andrew Barnert wrote:
> But if you just teach people "spell that as except BaseException:" 
> (or, more likely, "... as except Exception:"), it's still the exact 
> same attractive nuisance. And, because "except:" is almost always a 
> red flag in novice code, but "except Exception:" is occasionally 
> reasonable, you're making it a tiny bit harder to spot the mistake 
> when helping novices, without actually fixing it.

I think it is kind of a false argument to say 'this should not be 
considered because people will just break it another way'.

Bare excepts were a mistake.  I for one would support removing them in 
2.7.10, but that's not on the table.  As long as the 'new valid' syntax 
is also valid 2.7-3.5, it should be considered.

As I understand the proposal, `except ASubclassOfException:` would 
remain valid - an Exception type or object being required for an except 
clause is not a massive break in 2.7 (its already required there if you 
are not using bare excepts).  The burden of supporting 2.7 through a 
hypothetical 3.6 without being able to use bare exceptions is minimal to 
none.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150411/eaad03eb/attachment.html>


More information about the Python-ideas mailing list