]> granicus.if.org Git - llvm/commitdiff
[lit] Fix another Python 3 error.
authorZachary Turner <zturner@google.com>
Sat, 16 Sep 2017 00:43:16 +0000 (00:43 +0000)
committerZachary Turner <zturner@google.com>
Sat, 16 Sep 2017 00:43:16 +0000 (00:43 +0000)
Apparently we have a buildbot running Python 3.  This is going
to be fun :-/

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313428 91177308-0d34-0410-b5e6-96231b3b80d8

utils/lit/lit/util.py

index 7f3fcc8079a7a33a5aa7e512af0d2a5b40f62f31..c36dd589246779e8248ede3b19a4e4586c7c00bc 100644 (file)
@@ -11,13 +11,20 @@ import threading
 
 
 def pythonize_bool(value):
+    def is_string(value):
+        try:
+            # Python 2 and Python 3 are different here.
+            return isinstance(value, basestring)
+        except NameError:
+            return isinstance(value, str)
+
     if value is None:
         return False
     if type(value) is bool:
         return value
     if isinstance(value, numbers.Number):
         return value != 0
-    if isinstance(value, basestring):
+    if is_string(value):
         if value.lower() in ('1', 'true', 'on', 'yes'):
             return True
         if value.lower() in ('', '0', 'false', 'off', 'no'):