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 <gnu...@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 <gnu...@cyberdimension.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilira...@gmail.com>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-CC: neels <nhofm...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to