ModemATCommandLink: fix AttributeError exception in __del__()
self._sl will not be assigned if serial.Serial() fails.
Change-Id: I179a7efd92eaa3469a17b6ef252b3949c44ea6ea
diff --git a/pySim/transport/modem_atcmd.py b/pySim/transport/modem_atcmd.py
index 43614f1..2018ac2 100644
--- a/pySim/transport/modem_atcmd.py
+++ b/pySim/transport/modem_atcmd.py
@@ -43,7 +43,8 @@
self.reset_card()
def __del__(self):
- self._sl.close()
+ if hasattr(self, '_sl'):
+ self._sl.close()
def send_at_cmd(self, cmd, timeout=0.2, patience=0.002):
# Convert from string to bytes, if needed