Skip to content

Commit

Permalink
Fix cleanup when no device was found
Browse files Browse the repository at this point in the history
  • Loading branch information
yhql committed Mar 3, 2023
1 parent 48e6e7b commit 5fc73f6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ledgerwallet/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class NoLedgerDeviceException(Exception):

class LedgerClient(object):
def __init__(self, device=None, cla=0xE0, private_key=None):
self.device = None
if device is None:
devices = enumerate_devices()
if len(devices) == 0:
Expand All @@ -184,7 +185,8 @@ def __del__(self):
self.close()

def close(self):
self.device.close()
if self.device is not None:
self.device.close()

def raw_exchange(self, data: bytes) -> bytes:
LOG.debug("=> " + data.hex())
Expand Down

0 comments on commit 5fc73f6

Please sign in to comment.