Opened 9 years ago
Closed 9 years ago
#25682 closed Cleanup/optimization (fixed)
Audit bare except clauses
Reported by: | Aymeric Augustin | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
There are ten instances of except:
in the code base.
(Jacob just brilliantly showed one on stage.)
We should review them and at a minimum convert them to except Exception:
.
If we're actually trying to handle MemoryError
, we should do so it explicitly.
Change History (5)
comment:1 by , 9 years ago
Summary: | Bare except clauses → Audit bare except clauses |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 9 years ago
comment:4 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
I think I mentioned
MemoryError
when we were discussing this, but it seems I was mistaken -- MemoryError actually does inherit from Exception. Per the docs (https://docs.python.org/3/library/exceptions.html#exception-hierarchy and https://docs.python.org/2/library/exceptions.html#exception-hierarchy), the only built-in exceptions which do not inherit Exception are SystemExit, GeneratorExit, and KeyboardInterrupt. I think it is safe to say that if we want to handle any of those, we should do so explicitly, not through a bareexcept
.