[libcxx-commits] [libcxx] r365855 - Tolerate import errors in "not.py" implementation

Eric Fiselier via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 11 18:13:05 PDT 2019


Author: ericwf
Date: Thu Jul 11 18:13:05 2019
New Revision: 365855

URL: http://llvm.org/viewvc/llvm-project?rev=365855&view=rev
Log:
Tolerate import errors in "not.py" implementation

Modified:
    libcxx/trunk/utils/not.py

Modified: libcxx/trunk/utils/not.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/not.py?rev=365855&r1=365854&r2=365855&view=diff
==============================================================================
--- libcxx/trunk/utils/not.py (original)
+++ libcxx/trunk/utils/not.py Thu Jul 11 18:13:05 2019
@@ -12,10 +12,20 @@ ex: python /path/to/not.py ' echo hello
     echo $? // (prints 1)
 """
 
-import distutils.spawn
 import subprocess
 import sys
 
+def which_cannot_find_program(prog):
+    # Allow for import errors on distutils.spawn
+    try:
+        import distutils.spawn
+        prog = distutils.spawn.find_executable(prog[0])
+        if prog is None:
+            sys.stderr.write('Failed to find program %s' % prog[0])
+            return True
+        return False
+    except:
+        return False
 
 def main():
     argv = list(sys.argv)
@@ -27,9 +37,7 @@ def main():
         expectCrash = False
     if len(argv) == 0:
         return 1
-    prog = distutils.spawn.find_executable(argv[0])
-    if prog is None:
-        sys.stderr.write('Failed to find program %s' % argv[0])
+    if which_cannot_find_program(argv[0]):
         return 1
     rc = subprocess.call(argv)
     if rc < 0:




More information about the libcxx-commits mailing list