Page MenuHomePhabricator

[python linting] enforce E722: do not use bare except
ClosedPublic

Authored by markblundeberg on Feb 7 2020, 17:38.

Details

Summary

Generally using except: is a mistake since it catches everything
including SystemExit / KeyboardInterrupt / etc.... When we really
do want such a catch we should explicitly use except BaseException:,
otherwise we normally want except Exception: or even better, name
the specific exception that might occur.

Depends on D5204 D5206

Test Plan
arc lint --everything
ninja check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

test/functional/rpc_preciousblock.py
18 ↗(On Diff #16135)

I'm still not quite sure why this loop is made like this, or what exactly it is catching.

test/functional/test_framework/test_framework.py
323 ↗(On Diff #16135)

Probably the only place we want to have keyboard interrupts being caught... I think.

.arclint
29 ↗(On Diff #16135)

The remaining four are:

E501 	Line too long (82 > 79 characters)
E704 	Multiple statements on one line (def)
W503 	Line break occurred before a binary operator
W504 	Line break occurred after a binary operator

They have a bunch of violations and in fact the latter three are not even enabled by default in flake8.

This is about as far as we can get with the low hanging fruit.

This revision is now accepted and ready to land.Feb 7 2020, 18:03