Index: Misc/NEWS =================================================================== --- Misc/NEWS (révision 80971) +++ Misc/NEWS (copie de travail) @@ -351,6 +351,8 @@ Library ------- +- Issue #8513: subprocess supports bytes program name (on Unix) + - Issue #8514: Add os.fsencode() function (Unix only): encode a string to bytes for use in the file system, environment variables or the command line. Index: Lib/os.py =================================================================== --- Lib/os.py (révision 80971) +++ Lib/os.py (copie de travail) @@ -355,7 +355,11 @@ return last_exc = saved_exc = None saved_tb = None - for dir in get_exec_path(env): + path_list = get_exec_path(env) + if name != "nt": + file = fsencode(file) + path_list = (fsencode(dir) for dir in path_list) + for dir in path_list: fullname = path.join(dir, file) try: exec_func(fullname, *argrest) Index: Lib/test/test_subprocess.py =================================================================== --- Lib/test/test_subprocess.py (révision 80970) +++ Lib/test/test_subprocess.py (copie de travail) @@ -825,7 +825,18 @@ stdout = stdout.rstrip(b'\n\r') self.assertEquals(stdout.decode('ascii'), repr(value)) + def test_bytes_program(self): + # bytes program, unicode PATH + path, program = os.path.split(sys.executable) + program = os.fsencode(program) + env = os.environ.copy() + env["PATH"] = path + exitcode = subprocess.call( + [program, "-c", "pass"], + env=env) + self.assertEquals(exitcode, 0) + @unittest.skipUnless(mswindows, "Windows specific tests") class Win32ProcessTestCase(BaseTestCase): Index: Lib/subprocess.py =================================================================== --- Lib/subprocess.py (révision 80971) +++ Lib/subprocess.py (copie de travail) @@ -1094,10 +1094,10 @@ 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 = os.fsencode(executable) + executable_list = tuple( + os.path.join(os.fsencode(dir), executable) + for dir in path_list) self.pid = _posixsubprocess.fork_exec( args, executable_list, close_fds, cwd, env_list,