aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2019-09-12 15:03:23 +0200
committerlaforge <laforge@osmocom.org>2019-09-28 12:45:31 +0000
commit8902bcde0756e25632707e65c27ded49c719a9e0 (patch)
tree05b22f6ecde3f88d133ef1cc33c2e30692b64f40
parent84d2cb3cb3dd48fa98054ab786df0f2a66f575e4 (diff)
python3 conversion: Use python 2 and 3 compatible exceptionsHEADmaster
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@cyberdimension.org> Change-Id: Ie45dc7ccd72fe077ba3b424f221ff4ed02db436c
-rw-r--r--pySim/exceptions.py13
1 files changed, 8 insertions, 5 deletions
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
-
+try:
+ # This is for compatibility with python 2 and 3
+ from exceptions import Exception
+except:
+ pass
-class NoCardError(exceptions.Exception):
+class NoCardError(Exception):
pass
-class ProtocolError(exceptions.Exception):
+class ProtocolError(Exception):
pass
-class ReaderError(exceptions.Exception):
+class ReaderError(Exception):
pass