[rtems-source-builder commit] pkgconfig.py: Removed use of "unicode" keyword for python3 compatibility

Chris Johns chrisj at rtems.org
Sat Sep 26 01:00:02 UTC 2020


Module:    rtems-source-builder
Branch:    5
Commit:    e32e184d69b3a54059c9bf9a72a037eb7f9de6db
Changeset: http://git.rtems.org/rtems-source-builder/commit/?id=e32e184d69b3a54059c9bf9a72a037eb7f9de6db

Author:    Stephen Clark <stephen.clark at oarcorp.com>
Date:      Wed Sep 23 16:00:55 2020 -0500

pkgconfig.py: Removed use of "unicode" keyword for python3 compatibility

Closes #4094.

---

 source-builder/sb/pkgconfig.py | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/source-builder/sb/pkgconfig.py b/source-builder/sb/pkgconfig.py
index 99646f7..afc259b 100755
--- a/source-builder/sb/pkgconfig.py
+++ b/source-builder/sb/pkgconfig.py
@@ -103,6 +103,22 @@ class package(object):
         dst.nodes = copy.copy(src.nodes)
 
     @staticmethod
+    def _is_string(us):
+        if type(us) == str:
+            return True
+        try:
+            if type(us) == unicode:
+                return True
+        except:
+            pass
+        try:
+            if type(us) == bytes:
+                return True
+        except:
+            pass
+        return False
+
+    @staticmethod
     def is_version(v):
         for n in v.split('.'):
             if not n.isdigit():
@@ -214,7 +230,7 @@ class package(object):
             prefix = default_prefix()
         if prefix:
             self._log('prefix: %s' % (prefix))
-            if type(prefix) is str or type(prefix) is unicode:
+            if self._is_string(prefix):
                 prefix = str(prefix)
                 self.prefix = []
                 for p in prefix.split(os.pathsep):



More information about the vc mailing list