diff Lib/subprocess.py @ 61693:cf74ec3e1f82

Issue #8513: os.get_exec_path() supports b'PATH' key and bytes value. subprocess.Popen() and os._execvpe() support bytes program name. Add os.supports_bytes_environ flag: True if the native OS type of the environment is bytes (eg. False on Windows).
author Victor Stinner <victor.stinner@haypocalc.com>
date Tue, 18 May 2010 17:17:23 +0000
parents fa902f8e0db0
children 441491572fce
line wrap: on
line diff
--- a/Lib/subprocess.py	Tue May 18 14:15:20 2010 +0000
+++ b/Lib/subprocess.py	Tue May 18 17:17:23 2010 +0000
@@ -1096,15 +1096,14 @@
                                         for k, v in env.items()]
                         else:
                             env_list = None  # Use execv instead of execve.
+                        executable = os.fsencode(executable)
                         if os.path.dirname(executable):
-                            executable_list = (os.fsencode(executable),)
+                            executable_list = (executable,)
                         else:
                             # This matches the behavior of os._execvpe().
-                            path_list = os.get_exec_path(env)
-                            executable_list = (os.path.join(dir, executable)
-                                               for dir in path_list)
-                            executable_list = tuple(os.fsencode(exe)
-                                                    for exe in executable_list)
+                            executable_list = tuple(
+                                os.path.join(os.fsencode(dir), executable)
+                                for dir in os.get_exec_path(env))
                         self.pid = _posixsubprocess.fork_exec(
                                 args, executable_list,
                                 close_fds, cwd, env_list,