From 289fd28091e046868c64d29658db45f88e24900f Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Mon, 22 Feb 2021 16:20:43 +0100 Subject: serial: do not try to close non existing serial connection The SerialSimLink only has an _sl member if serial initalization was successfull. If we close a serial connection, check if we even have the _sl member. Otherwise move on silently. Change-Id: Ic3f3f5e50d780f424da7d0be5733d7167bb7159c --- pySim/transport/serial.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pySim/transport/serial.py b/pySim/transport/serial.py index b841b3e..7785b4a 100644 --- a/pySim/transport/serial.py +++ b/pySim/transport/serial.py @@ -52,7 +52,8 @@ class SerialSimLink(LinkBase): self._atr = None def __del__(self): - self._sl.close() + if (hasattr(self, "_sl")): + self._sl.close() def wait_for_card(self, timeout=None, newcardonly=False): # Direct try -- cgit v1.2.3