Skip to content

Commit 61bb4e7

Browse files
committed
lint: enable E722 do not use bare except
1 parent 73b6171 commit 61bb4e7

File tree

10 files changed

+11
-10
lines changed

10 files changed

+11
-10
lines changed

contrib/devtools/security-check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def check_ELF_RELRO(binary) -> bool:
3434
flags = binary.get(lief.ELF.DYNAMIC_TAGS.FLAGS)
3535
if flags.value & lief.ELF.DYNAMIC_FLAGS.BIND_NOW:
3636
have_bindnow = True
37-
except:
37+
except Exception:
3838
have_bindnow = False
3939

4040
return have_gnu_relro and have_bindnow

contrib/signet/getcoins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def bitcoin_cli(rpc_command_and_params):
142142

143143
try:
144144
res = session.post(args.faucet, data=data)
145-
except:
145+
except Exception:
146146
raise SystemExit(f"Unexpected error when contacting faucet: {sys.exc_info()[0]}")
147147

148148
# Display the output as per the returned status code

test/functional/feature_dbcrash.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def restart_node(self, node_index, expected_tip):
8585
self.nodes[node_index].waitforblock(expected_tip)
8686
utxo_hash = self.nodes[node_index].gettxoutsetinfo()['hash_serialized_2']
8787
return utxo_hash
88-
except:
88+
except Exception:
8989
# An exception here should mean the node is about to crash.
9090
# If bitcoind exits, then try again. wait_for_node_exit()
9191
# should raise an exception if bitcoind doesn't exit.

test/functional/p2p_node_network_limited.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def run_test(self):
8585
self.connect_nodes(0, 2)
8686
try:
8787
self.sync_blocks([self.nodes[0], self.nodes[2]], timeout=5)
88-
except:
88+
except Exception:
8989
pass
9090
# node2 must remain at height 0
9191
assert_equal(self.nodes[2].getblockheader(self.nodes[2].getbestblockhash())['height'], 0)

test/functional/rpc_preciousblock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def unidirectional_node_sync_via_rpc(node_src, node_dest):
1616
try:
1717
assert len(node_dest.getblock(blockhash, False)) > 0
1818
break
19-
except:
19+
except Exception:
2020
blocks_to_copy.append(blockhash)
2121
blockhash = node_src.getblockheader(blockhash, True)['previousblockhash']
2222
blocks_to_copy.reverse()

test/functional/test_framework/p2p.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ def on_message(self, message):
383383
self.message_count[msgtype] += 1
384384
self.last_message[msgtype] = message
385385
getattr(self, 'on_' + msgtype)(message)
386-
except:
386+
except Exception:
387387
print("ERROR delivering %s (%s)" % (repr(message), sys.exc_info()[0]))
388388
raise
389389

test/functional/test_framework/test_framework.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def start_nodes(self, extra_args=None, *args, **kwargs):
547547
node.start(extra_args[i], *args, **kwargs)
548548
for node in self.nodes:
549549
node.wait_for_rpc_connection()
550-
except:
550+
except Exception:
551551
# If one node failed to start, stop the others
552552
self.stop_nodes()
553553
raise

test/functional/test_framework/test_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ def importaddress(self, address, label=None, rescan=None, p2sh=None):
805805
int(address ,16)
806806
is_hex = True
807807
desc = descsum_create('raw(' + address + ')')
808-
except:
808+
except Exception:
809809
desc = descsum_create('addr(' + address + ')')
810810
reqs = [{
811811
'desc': desc,

test/lint/lint-python.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
'E711,' # comparison to None should be 'if cond is None:'
4848
'E714,' # test for object identity should be "is not"
4949
'E721,' # do not compare types, use "isinstance()"
50+
'E722,' # do not use bare 'except'
5051
'E742,' # do not define classes named "l", "O", or "I"
5152
'E743,' # do not define functions named "l", "O", or "I"
5253
'E901,' # SyntaxError: invalid syntax

test/util/test_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def bctester(testDir, input_basename, buildenv):
5454
try:
5555
bctest(testDir, testObj, buildenv)
5656
logging.info("PASSED: " + testObj["description"])
57-
except:
57+
except Exception:
5858
logging.info("FAILED: " + testObj["description"])
5959
failed_testcases.append(testObj["description"])
6060

@@ -96,7 +96,7 @@ def bctest(testDir, testObj, buildenv):
9696
try:
9797
with open(os.path.join(testDir, outputFn), encoding="utf8") as f:
9898
outputData = f.read()
99-
except:
99+
except Exception:
100100
logging.error("Output file " + outputFn + " cannot be opened")
101101
raise
102102
if not outputData:

0 commit comments

Comments
 (0)