mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +00:00
core: throw exception classes instead of instances where possible
This commit is contained in:
parent
312224b7a3
commit
e3e2811f7a
@ -92,7 +92,7 @@ def _cbor_encode(value):
|
||||
else:
|
||||
if __debug__:
|
||||
log.debug(__name__, "not implemented (encode): %s", type(value))
|
||||
raise NotImplementedError()
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def _read_length(cbor, aux):
|
||||
@ -193,11 +193,11 @@ def _cbor_decode(cbor):
|
||||
elif fb_aux == _CBOR_BREAK:
|
||||
return (cbor[0], cbor[1:])
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
raise NotImplementedError
|
||||
else:
|
||||
if __debug__:
|
||||
log.debug(__name__, "not implemented (decode): %s", cbor[0])
|
||||
raise NotImplementedError()
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class Tagged:
|
||||
@ -233,5 +233,5 @@ def encode(value):
|
||||
def decode(cbor: bytes):
|
||||
res, check = _cbor_decode(cbor)
|
||||
if not (check == b""):
|
||||
raise ValueError()
|
||||
raise ValueError
|
||||
return res
|
||||
|
@ -29,5 +29,5 @@ async def request_pin(
|
||||
else:
|
||||
result = await dialog
|
||||
if result is CANCELLED:
|
||||
raise PinCancelled()
|
||||
raise PinCancelled
|
||||
return result
|
||||
|
@ -298,7 +298,7 @@ class KeyVBase:
|
||||
return memcpy(buff, offset, self[self.idxize(idx)], 0, 32)
|
||||
|
||||
def read(self, idx, buff, offset=0):
|
||||
raise ValueError()
|
||||
raise ValueError
|
||||
|
||||
def slice(self, res, start, stop):
|
||||
for i in range(start, stop):
|
||||
@ -583,7 +583,7 @@ class KeyVPowers(KeyVBase):
|
||||
elif item == prev + 1:
|
||||
return sc_mul(self.cur, self.cur, self.x)
|
||||
else:
|
||||
IndexError("Only linear scan allowed")
|
||||
raise IndexError("Only linear scan allowed")
|
||||
|
||||
|
||||
class KeyVZtwo(KeyVBase):
|
||||
@ -827,7 +827,7 @@ def vector_z_two(N, logN, M, zpow, twoN, zero_twos=None, dynamic=False, **kwargs
|
||||
if dynamic:
|
||||
return KeyVZtwo(N, logN, M, zpow, twoN, **kwargs)
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def hash_cache_mash(dst, hash_cache, *args):
|
||||
|
@ -56,7 +56,7 @@ def unimport_end(mods):
|
||||
def ensure(cond, msg=None):
|
||||
if not cond:
|
||||
if msg is None:
|
||||
raise AssertionError()
|
||||
raise AssertionError
|
||||
else:
|
||||
raise AssertionError(msg)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user