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.
This commit is contained in:
Benjamin Peterson
2019-10-29 11:48:36 -07:00
committed by Jelle Zijlstra
parent e6c467af82
commit 2023394b37

View File

@@ -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: ...