From 2023394b37430878ebd4df2687a19fc50d4ad723 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Tue, 29 Oct 2019 11:48:36 -0700 Subject: [PATCH] exec, spawn: Allow bytes for environment keys and values. (#3419) A more correct type would be Mapping[Union[bytes, str], Union[bytes, str]], but our hands are tied by the invariance of mapping keys. --- stdlib/3/os/__init__.pyi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stdlib/3/os/__init__.pyi b/stdlib/3/os/__init__.pyi index b17a55736..5e36cc14d 100644 --- a/stdlib/3/os/__init__.pyi +++ b/stdlib/3/os/__init__.pyi @@ -557,10 +557,11 @@ def execlpe(file: _PathType, __arg0: Union[bytes, Text], *args: Any) -> NoReturn # The docs say `args: tuple or list of strings` # The implementation enforces tuple or list so we can't use Sequence. _ExecVArgs = Union[Tuple[Union[bytes, Text], ...], List[bytes], List[Text], List[Union[bytes, Text]]] +_ExecEnv = Union[Mapping[bytes, Union[bytes, str]], Mapping[str, Union[bytes, str]]] def execv(path: _PathType, args: _ExecVArgs) -> NoReturn: ... -def execve(path: _FdOrPathType, args: _ExecVArgs, env: Mapping[str, str]) -> NoReturn: ... +def execve(path: _FdOrPathType, args: _ExecVArgs, env: _ExecEnv) -> NoReturn: ... def execvp(file: _PathType, args: _ExecVArgs) -> NoReturn: ... -def execvpe(file: _PathType, args: _ExecVArgs, env: Mapping[str, str]) -> NoReturn: ... +def execvpe(file: _PathType, args: _ExecVArgs, env: _ExecEnv) -> NoReturn: ... def _exit(n: int) -> NoReturn: ... def kill(pid: int, sig: int) -> None: ... @@ -581,7 +582,7 @@ def spawnle(mode: int, path: _PathType, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise sig def spawnv(mode: int, path: _PathType, args: List[Union[bytes, Text]]) -> int: ... def spawnve(mode: int, path: _PathType, args: List[Union[bytes, Text]], - env: Mapping[str, str]) -> int: ... + env: _ExecEnv) -> int: ... def system(command: _PathType) -> int: ... def times() -> times_result: ... def waitpid(pid: int, options: int) -> Tuple[int, int]: ... @@ -593,7 +594,7 @@ else: def spawnlp(mode: int, file: _PathType, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ... def spawnlpe(mode: int, file: _PathType, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise signature def spawnvp(mode: int, file: _PathType, args: List[Union[bytes, Text]]) -> int: ... - def spawnvpe(mode: int, file: _PathType, args: List[Union[bytes, Text]], env: Mapping[str, str]) -> int: ... + def spawnvpe(mode: int, file: _PathType, args: List[Union[bytes, Text]], env: _ExecEnv) -> int: ... def wait() -> Tuple[int, int]: ... # Unix only from posix import waitid_result def waitid(idtype: int, ident: int, options: int) -> waitid_result: ...