Change in ...pysim[master]: python3 conversion: Use python 2 and 3 compatible exceptions

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Mon Oct 7 20:03:08 UTC 2019


laforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/pysim/+/15503 )

Change subject: python3 conversion: Use python 2 and 3 compatible exceptions
......................................................................

python3 conversion: Use python 2 and 3 compatible exceptions

Without that we have:
  $ python3 pySim-read.py
  Using serial reader (port=/dev/ttyUSB0, baudrate=9600) interface
  Traceback (most recent call last):
    File "pySim-read.py", line 91, in <module>
      from pySim.transport.serial import SerialSimLink
    File "/home/gnutoo/work/projects/osmocom/pysim/pySim/transport/serial.py", line 29, in <module>
      from pySim.exceptions import NoCardError, ProtocolError
    File "/home/gnutoo/work/projects/osmocom/pysim/pySim/exceptions.py", line 26, in <module>
      import exceptions
  ModuleNotFoundError: No module named 'exceptions'

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
Change-Id: Ie45dc7ccd72fe077ba3b424f221ff4ed02db436c
---
M pySim/exceptions.py
1 file changed, 9 insertions(+), 6 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/pySim/exceptions.py b/pySim/exceptions.py
index 831b1c9..68303e1 100644
--- a/pySim/exceptions.py
+++ b/pySim/exceptions.py
@@ -23,14 +23,17 @@
 
 from __future__ import absolute_import
 
-import exceptions
-
-
-class NoCardError(exceptions.Exception):
+try:
+	# This is for compatibility with python 2 and 3
+	from exceptions import Exception
+except:
 	pass
 
-class ProtocolError(exceptions.Exception):
+class NoCardError(Exception):
 	pass
 
-class ReaderError(exceptions.Exception):
+class ProtocolError(Exception):
+	pass
+
+class ReaderError(Exception):
 	pass

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie45dc7ccd72fe077ba3b424f221ff4ed02db436c
Gerrit-Change-Number: 15503
Gerrit-PatchSet: 5
Gerrit-Owner: gnutoo <GNUtoo at cyberdimension.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-CC: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191007/73abba00/attachment.htm>


More information about the gerrit-log mailing list