run-tests: fix _findprogram to reliably return bytes
authorAugie Fackler <augie@google.com>
Tue, 14 Apr 2015 15:56:44 -0400
changeset 25038 66da89457c47
parent 25037 570141fa38f9
child 25039 8505eb1bafb1
run-tests: fix _findprogram to reliably return bytes
tests/run-tests.py
--- a/tests/run-tests.py	Tue Apr 14 15:54:13 2015 -0400
+++ b/tests/run-tests.py	Tue Apr 14 15:56:44 2015 -0400
@@ -2099,7 +2099,13 @@
 
     def _findprogram(self, program):
         """Search PATH for a executable program"""
-        for p in os.environ.get('PATH', os.defpath).split(os.pathsep):
+        if sys.version_info[0] > 2:
+            dpb = os.defpath.encode('utf-8')
+            sepb = os.pathsep.encode('utf-8')
+        else:
+            dpb = os.defpath
+            sepb = os.pathsep
+        for p in osenvironb.get(b'PATH', dpb).split(sepb):
             name = os.path.join(p, program)
             if os.name == 'nt' or os.access(name, os.X_OK):
                 return name