From 8902bcde0756e25632707e65c27ded49c719a9e0 Mon Sep 17 00:00:00 2001 From: Denis 'GNUtoo' Carikli Date: Thu, 12 Sep 2019 15:03:23 +0200 Subject: 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 from pySim.transport.serial import SerialSimLink File "/home/gnutoo/work/projects/osmocom/pysim/pySim/transport/serial.py", line 29, in from pySim.exceptions import NoCardError, ProtocolError File "/home/gnutoo/work/projects/osmocom/pysim/pySim/exceptions.py", line 26, in import exceptions ModuleNotFoundError: No module named 'exceptions' Signed-off-by: Denis 'GNUtoo' Carikli Change-Id: Ie45dc7ccd72fe077ba3b424f221ff4ed02db436c --- pySim/exceptions.py | 13 ++++++++----- 1 file 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 -- cgit v1.2.3