From ce3a76bb97c2bedfc3c61401770f95def1abeffd Mon Sep 17 00:00:00 2001 From: David Euresti Date: Wed, 22 Mar 2017 10:50:15 -0700 Subject: [PATCH] Fix arg types for os.execv* (#1075) --- stdlib/2/os/__init__.pyi | 13 +++++++++---- stdlib/3/os/__init__.pyi | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/stdlib/2/os/__init__.pyi b/stdlib/2/os/__init__.pyi index f96aae352..17b1162da 100644 --- a/stdlib/2/os/__init__.pyi +++ b/stdlib/2/os/__init__.pyi @@ -201,10 +201,15 @@ def execl(file: _PathType, *args) -> None: ... def execle(file: _PathType, *args) -> None: ... def execlp(file: _PathType, *args) -> None: ... def execlpe(file: _PathType, *args) -> None: ... -def execv(path: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]]) -> None: ... -def execve(path: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]], env: Mapping[str, str]) -> None: ... -def execvp(file: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]]) -> None: ... -def execvpe(file: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]], env: Mapping[str, str]) -> None: ... + +# 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]]] +def execv(path: _PathType, args: _ExecVArgs) -> None: ... +def execve(path: _PathType, args: _ExecVArgs, env: Mapping[str, str]) -> None: ... +def execvp(file: _PathType, args: _ExecVArgs) -> None: ... +def execvpe(file: _PathType, args: _ExecVArgs, env: Mapping[str, str]) -> None: ... + def _exit(n: int) -> NoReturn: ... def fork() -> int: ... def forkpty() -> Tuple[int, int]: ... diff --git a/stdlib/3/os/__init__.pyi b/stdlib/3/os/__init__.pyi index a4f5ccb06..9c1bcaf5b 100644 --- a/stdlib/3/os/__init__.pyi +++ b/stdlib/3/os/__init__.pyi @@ -346,10 +346,15 @@ def execle(path: _PathType, arg0: Union[bytes, Text], def execlp(path: _PathType, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> None: ... def execlpe(path: _PathType, arg0: Union[bytes, Text], *args: Any) -> None: ... # Imprecise signature -def execv(path: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]]) -> None: ... -def execve(path: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]], env: Mapping[str, str]) -> None: ... -def execvp(file: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]]) -> None: ... -def execvpe(file: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]], env: Mapping[str, str]) -> None: ... + +# 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]]] +def execv(path: _PathType, args: _ExecVArgs) -> None: ... +def execve(path: _PathType, args: _ExecVArgs, env: Mapping[str, str]) -> None: ... +def execvp(file: _PathType, args: _ExecVArgs) -> None: ... +def execvpe(file: _PathType, args: _ExecVArgs, env: Mapping[str, str]) -> None: ... + def _exit(n: int) -> NoReturn: ... def fork() -> int: ... # Unix only def forkpty() -> Tuple[int, int]: ... # some flavors of Unix