Index: Lib/os.py =================================================================== --- Lib/os.py (révision 80889) +++ Lib/os.py (copie de travail) @@ -355,7 +355,14 @@ 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": + if isinstance(file, str): + file = file.encode(sys.getfilesystemencoding(), 'surrogateescape') + path_list = ( + dir.encode(sys.getfilesystemencoding(), 'surrogateescape') + 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 80889) +++ Lib/test/test_subprocess.py (copie de travail) @@ -825,7 +825,21 @@ stdout = stdout.rstrip(b'\n\r') self.assertEquals(stdout.decode('ascii'), repr(value)) + def test_bytes_program(self): + def fs_encode(filename): + return filename.encode(sys.getfilesystemencoding(), "surrogateescape") + # bytes program, unicode PATH + path, program = os.path.split(sys.executable) + program = fs_encode(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 80889) +++ Lib/subprocess.py (copie de travail) @@ -1102,10 +1102,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(fs_encode(exe) - for exe in executable_list) + executable = fs_encode(executable) + executable_list = tuple( + os.path.join(fs_encode(dir), executable) + for dir in path_list) self.pid = _posixsubprocess.fork_exec( args, executable_list, close_fds, cwd, env_list,