[rtems-tools commit] Python 2 and python 3 refactor fixes.

Chris Johns chrisj at rtems.org
Wed Mar 9 03:42:46 UTC 2016


Module:    rtems-tools
Branch:    4.11
Commit:    6359063eb95f2495fb4b4ff879a02864cafc9fe9
Changeset: http://git.rtems.org/rtems-tools/commit/?id=6359063eb95f2495fb4b4ff879a02864cafc9fe9

Author:    Chris Johns <chrisj at rtems.org>
Date:      Wed Mar  9 14:39:43 2016 +1100

Python 2 and python 3 refactor fixes.

Updates #2619.

---

 rtemstoolkit/execute.py | 3 ++-
 rtemstoolkit/macros.py  | 1 +
 tester/rt/test.py       | 5 ++++-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/rtemstoolkit/execute.py b/rtemstoolkit/execute.py
index 147d501..0dc9d4c 100755
--- a/rtemstoolkit/execute.py
+++ b/rtemstoolkit/execute.py
@@ -185,7 +185,8 @@ class execute(object):
                     data = fh.read(1)
                     if len(data) == 0:
                         break
-                    if type(data) == bytes:
+                    # str and bytes are the same type in Python2
+                    if type(data) is not str and type(data) is bytes:
                         data = data.decode(sys.stdout.encoding)
                     for c in data:
                         line += c
diff --git a/rtemstoolkit/macros.py b/rtemstoolkit/macros.py
index c9410ae..4eb8829 100644
--- a/rtemstoolkit/macros.py
+++ b/rtemstoolkit/macros.py
@@ -188,6 +188,7 @@ class macros:
         return macro[2]
 
     def __setitem__(self, key, value):
+        key = self._unicode_to_str(key)
         if type(key) is not str:
             raise TypeError('bad key type (want str): %s' % (type(key)))
         if type(value) is not tuple:
diff --git a/tester/rt/test.py b/tester/rt/test.py
index c118382..72b5fea 100644
--- a/tester/rt/test.py
+++ b/tester/rt/test.py
@@ -120,7 +120,10 @@ class test_run(object):
 
     def reraise(self):
         if self.result is not None:
-            raise self.result[0](self.result[1]).with_traceback(self.result[2])
+            with_tb = getattr(self.result[1], 'with_traceback', None)
+            if with_tb:
+                raise self.result[1].with_traceback(self.result[2])
+            raise (self.result[0], self.result[1], self.result[2])
 
     def kill(self):
         if self.test:




More information about the vc mailing list