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 Tim Graham, 9 years ago

Summary: Bare except clausesAudit bare except clauses
Triage Stage: UnreviewedAccepted

comment:2 by Carl Meyer, 9 years ago

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 bare except.

comment:3 by Tim Graham, 9 years ago

Has patch: set

comment:4 by Tim Graham, 9 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 0a2d3b7:

Fixed #25682 -- Removed bare except clauses.

Note: See TracTickets for help on using tickets.
Back to Top