Skip to content

Commit b120c87

Browse files
committed
Avoided bare except
1 parent 6c1d4e4 commit b120c87

9 files changed

+18
-18
lines changed

btchip/btchip.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ def __init__(self, dongle):
8585
self.scriptBlockLength = 50
8686
else:
8787
self.scriptBlockLength = 255
88-
except:
88+
except Exception:
8989
pass
9090
try:
9191
result = self.getJCExtendedFeatures()
9292
self.needKeyCache = (result['proprietaryApi'] == False)
93-
except:
93+
except Exception:
9494
pass
9595

9696
def setAlternateCoinVersion(self, versionRegular, versionP2SH):
@@ -298,7 +298,7 @@ def finalizeInput(self, outputAddress, amount, fees, changePath, rawTx=None):
298298
response = self.dongle.exchange(bytearray(apdu))
299299
offset += dataLength
300300
alternateEncoding = True
301-
except:
301+
except Exception:
302302
pass
303303
if not alternateEncoding:
304304
apdu = [ self.BTCHIP_CLA, self.BTCHIP_INS_HASH_INPUT_FINALIZE, 0x02, 0x00 ]

btchip/btchipComm.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def close(self):
142142
if self.opened:
143143
try:
144144
self.device.close()
145-
except:
145+
except Exception:
146146
pass
147147
self.opened = False
148148

@@ -169,7 +169,7 @@ def close(self):
169169
if self.opened:
170170
try:
171171
self.device.disconnect()
172-
except:
172+
except Exception:
173173
pass
174174
self.opened = False
175175

@@ -182,7 +182,7 @@ def __init__(self, server, port, debug=False):
182182
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
183183
try:
184184
self.socket.connect((self.server, self.port))
185-
except:
185+
except Exception:
186186
raise BTChipException("Proxy connection failed")
187187

188188
def exchange(self, apdu, timeout=20000):
@@ -202,7 +202,7 @@ def exchange(self, apdu, timeout=20000):
202202
def close(self):
203203
try:
204204
self.socket.close()
205-
except:
205+
except Exception:
206206
pass
207207

208208
def getDongle(debug=False):
@@ -244,7 +244,7 @@ def getDongle(debug=False):
244244
else:
245245
connection.disconnect()
246246
connection = None
247-
except:
247+
except Exception:
248248
connection = None
249249
pass
250250
if connection is not None:

btchip/btchipKeyRecovery.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ def recoverKey(signature, hashValue, keyX):
5252
candidate = point_to_ser(key.pubkey.point)
5353
if candidate[1:33] == keyX:
5454
return candidate
55-
except:
55+
except Exception:
5656
pass
5757
raise Exception("Key recovery failed")

btchip/btchipPersoWizard.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
try:
2626
from mnemonic import Mnemonic
2727
MNEMONIC = True
28-
except:
28+
except Exception:
2929
MNEMONIC = False
3030

3131
from .btchipComm import getDongle, DongleWait
@@ -51,7 +51,7 @@ def waitDongle(currentDialog, persoData):
5151
if persoData['client'] != None:
5252
try:
5353
persoData['client'].dongle.close()
54-
except:
54+
except Exception:
5555
pass
5656
dongle = getDongle(BTCHIP_DEBUG)
5757
persoData['client'] = btchip(dongle)
@@ -124,7 +124,7 @@ def processNext(self):
124124
seedText = seedText[0:-1]
125125
try:
126126
self.persoData['seed'] = seedText.decode('hex')
127-
except:
127+
except Exception:
128128
pass
129129
if self.persoData['seed'] == None:
130130
if not MNEMONIC:
@@ -279,7 +279,7 @@ def finish(self):
279279
if not self.persoData['hardened']:
280280
try:
281281
self.persoData['client'].setOperationMode(btchip.OPERATION_MODE_SERVER)
282-
except:
282+
except Exception:
283283
QMessageBox.warning(self, "Error", "Error switching to non hardened mode", "OK")
284284
self.reject()
285285
self.persoData['main'].reject()

samples/runScript.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
if len(line) == 0:
4646
continue
4747
dongle.exchange(bytearray(binascii.unhexlify(line)), timeout)
48-
except:
48+
except Exception:
4949
if cancelResponse:
5050
pass
5151
else:

tests/testMessageSignature.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
app = btchip(dongle)
3535
try:
3636
app.setup(btchip.OPERATION_MODE_WALLET, btchip.FEATURE_RFC6979, 0x00, 0x05, "1234", None, btchip.QWERTY_KEYMAP, SEED)
37-
except:
37+
except Exception:
3838
pass
3939
# Authenticate
4040
app.verifyPin("1234")

tests/testMultisigArmory.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
app = btchip(dongle)
139139
try:
140140
app.setup(btchip.OPERATION_MODE_RELAXED_WALLET, btchip.FEATURE_RFC6979, 111, 196, "1234", None, btchip.QWERTY_KEYMAP, SEED)
141-
except:
141+
except Exception:
142142
pass
143143
# Authenticate
144144
app.verifyPin("1234")

tests/testMultisigArmoryNo2FA.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
app = btchip(dongle)
137137
try:
138138
app.setup(btchip.OPERATION_MODE_RELAXED_WALLET, btchip.FEATURE_RFC6979|btchip.FEATURE_NO_2FA_P2SH, 111, 196, "1234", None, btchip.QWERTY_KEYMAP, SEED)
139-
except:
139+
except Exception:
140140
pass
141141
# Authenticate
142142
app.verifyPin("1234")

tests/testSimpleTransaction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
app = btchip(dongle)
4040
try:
4141
app.setup(btchip.OPERATION_MODE_WALLET, btchip.FEATURE_RFC6979, 0x00, 0x05, "1234", None, btchip.QWERTY_KEYMAP, SEED)
42-
except:
42+
except Exception:
4343
pass
4444
# Authenticate
4545
app.verifyPin("1234")

0 commit comments

Comments
 (0)