changeset 25038:66da89457c47

run-tests: fix _findprogram to reliably return bytes
author Augie Fackler <augie@google.com>
date Tue, 14 Apr 2015 15:56:44 -0400
parents 570141fa38f9
children 8505eb1bafb1
files tests/run-tests.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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