fix or remove except Exception rule

Bug #1184841 reported by Monty Taylor
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
hacking
Fix Released
Medium
Unassigned

Bug Description

From the original source:

"Never use catch-all except: statements, or catch Exception or StandardError, unless you are re-raising the exception or in the outermost block in your thread (and printing an error message). Python is very tolerant in this regard and except: will really catch everything including misspelled names, sys.exit() calls, Ctrl+C interrupts, unittest failures and all kinds of other exceptions that you simply don't want to catch."

I agree with the intent here - but I'm concerned that our implementation leaves out the "unless you are in the outermost block in your thread" - because I think that's a totally valid use case. Also, ours permits except Exception: in place of except: which I don't think was the intent. SO - I'd say that what we want in general would be:

Block use of except: or except Exception: or except StandardError: anywhere ... except:

Figure out a non-hacky way to allow expression of an except: in top loops.

Joe Gordon (jogo)
Changed in hacking:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Joe Gordon (jogo) wrote :

This check, H201, now supports noqa

Changed in hacking:
status: Confirmed → Fix Committed
Joe Gordon (jogo)
Changed in hacking:
milestone: none → 0.9.0
Joe Gordon (jogo)
Changed in hacking:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.