Change in pysim[master]: transport/pcsc: work around Python 3.5 bug: guard disconnect()

fixeria gerrit-no-reply at lists.osmocom.org
Sun Mar 7 19:26:08 UTC 2021


fixeria has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/17283 )

Change subject: transport/pcsc: work around Python 3.5 bug: guard disconnect()
......................................................................

transport/pcsc: work around Python 3.5 bug: guard disconnect()

Unfortunately, Debian ships old Python (3.5 vs 3.8) and old pyscard
(1.9.4 vs 1.9.9). Calling PCSCCardConnection.disconnect() from a
destructor causes warnings about ignored exceptions:

  AttributeError: 'NoneType' object has no attribute 'disconnect'
  AttributeError: 'NoneType' object has no attribute 'setChanged'
  AttributeError: 'NoneType' object has no attribute 'SCardDisconnect'
  TypeError: 'NoneType' object is not callable

All these exceptions happen in pyscard's own destructors.

Change-Id: I9c644bc5fe9791b141a30bfc13647d77937a82ee
---
M pySim/transport/pcsc.py
1 file changed, 5 insertions(+), 1 deletion(-)

Approvals:
  laforge: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/pySim/transport/pcsc.py b/pySim/transport/pcsc.py
index fadf6f9..2c2cbb9 100644
--- a/pySim/transport/pcsc.py
+++ b/pySim/transport/pcsc.py
@@ -39,7 +39,11 @@
 		self._con = self._reader.createConnection()
 
 	def __del__(self):
-		self._con.disconnect()
+		try:
+			# FIXME: this causes multiple warnings in Python 3.5.3
+			self._con.disconnect()
+		except:
+			pass
 		return
 
 	def wait_for_card(self, timeout=None, newcardonly=False):

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/17283
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I9c644bc5fe9791b141a30bfc13647d77937a82ee
Gerrit-Change-Number: 17283
Gerrit-PatchSet: 6
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210307/a6fe445d/attachment.htm>


More information about the gerrit-log mailing list