From d2bd996abe89a0bd3283072766612e8bd977415f Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 26 Oct 2026 13:36:47 +0000 Subject: [PATCH] ruff exceptions: KeyError --- mmgen/obj.py | 2 +- mmgen/passwdlist.py | 2 +- mmgen/proto/btc/rpc/local.py | 4 ++-- mmgen/rpc/local.py | 4 ++-- test/altcointest.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mmgen/obj.py b/mmgen/obj.py index ca2668ca..706766b1 100644 --- a/mmgen/obj.py +++ b/mmgen/obj.py @@ -154,7 +154,7 @@ class ListItemAttr(ImmutableAttr): "return None if attribute doesn't exist" try: return instance.__dict__[self.name] - except: + except KeyError: return None def setattr_condition(self, instance): diff --git a/mmgen/passwdlist.py b/mmgen/passwdlist.py index 0144b26a..1e9bc81a 100644 --- a/mmgen/passwdlist.py +++ b/mmgen/passwdlist.py @@ -165,7 +165,7 @@ class PasswordList(AddrList): pw_bytes = xmrseed().seedlen_map_rev[self.pw_len] try: good_pw_len = xmrseed().seedlen_map[seed.byte_len] - except: + except KeyError: die(1, f'{seed.byte_len*8}: unsupported seed length for Monero new-style mnemonic') case 'b32' | 'b58' as pf: pw_int = (32 if pf == 'b32' else 58) ** self.pw_len diff --git a/mmgen/proto/btc/rpc/local.py b/mmgen/proto/btc/rpc/local.py index e505022b..336e6ced 100644 --- a/mmgen/proto/btc/rpc/local.py +++ b/mmgen/proto/btc/rpc/local.py @@ -392,13 +392,13 @@ class BitcoinRPCClient(RPCClient, metaclass=AsyncInit): try: if d['softforks']['segwit']['active'] is True: return True - except: + except KeyError: pass try: if d['bip9_softforks']['segwit']['status'] == 'active': return True - except: + except KeyError: pass return self.cfg.test_suite and self.chain != 'regtest' diff --git a/mmgen/rpc/local.py b/mmgen/rpc/local.py index 5409f55e..58df7ee6 100644 --- a/mmgen/rpc/local.py +++ b/mmgen/rpc/local.py @@ -172,10 +172,10 @@ class RPCClient: t = json.loads(text) try: m = t['error']['message'] - except: + except KeyError: try: m = t['error'] - except: + except KeyError: m = t die('RPCFailure', m) else: diff --git a/test/altcointest.py b/test/altcointest.py index d7be3f16..9198a1e6 100755 --- a/test/altcointest.py +++ b/test/altcointest.py @@ -372,7 +372,7 @@ class TestCoinInfo(CoinInfo): try: bl = cls.external_tests_blacklist[addr_type][tool] - except: + except KeyError: pass else: if bl is True or coin in bl: