Opened 4 years ago

Closed 4 years ago

#25682 closed Cleanup/optimization (fixed)

Audit bare except clauses

Reported by: Aymeric Augustin Owned by: nobody
Component: Core (Other) Version: master
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 Changed 4 years ago by Tim Graham

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

comment:2 Changed 4 years ago by Carl Meyer

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 Changed 4 years ago by Tim Graham

Has patch: set

comment:4 Changed 4 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:5 Changed 4 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 0a2d3b7:

Fixed #25682 -- Removed bare except clauses.

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