Skip to content

Commit ce3a76b

Browse files
eurestiJelleZijlstra
authored andcommitted
Fix arg types for os.execv* (#1075)
1 parent 8318953 commit ce3a76b

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

stdlib/2/os/__init__.pyi

+9-4
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,15 @@ def execl(file: _PathType, *args) -> None: ...
201201
def execle(file: _PathType, *args) -> None: ...
202202
def execlp(file: _PathType, *args) -> None: ...
203203
def execlpe(file: _PathType, *args) -> None: ...
204-
def execv(path: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]]) -> None: ...
205-
def execve(path: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]], env: Mapping[str, str]) -> None: ...
206-
def execvp(file: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]]) -> None: ...
207-
def execvpe(file: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]], env: Mapping[str, str]) -> None: ...
204+
205+
# The docs say `args: tuple or list of strings`
206+
# The implementation enforces tuple or list so we can't use Sequence.
207+
_ExecVArgs = Union[Tuple[Union[bytes, Text], ...], List[bytes], List[Text], List[Union[bytes, Text]]]
208+
def execv(path: _PathType, args: _ExecVArgs) -> None: ...
209+
def execve(path: _PathType, args: _ExecVArgs, env: Mapping[str, str]) -> None: ...
210+
def execvp(file: _PathType, args: _ExecVArgs) -> None: ...
211+
def execvpe(file: _PathType, args: _ExecVArgs, env: Mapping[str, str]) -> None: ...
212+
208213
def _exit(n: int) -> NoReturn: ...
209214
def fork() -> int: ...
210215
def forkpty() -> Tuple[int, int]: ...

stdlib/3/os/__init__.pyi

+9-4
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,15 @@ def execle(path: _PathType, arg0: Union[bytes, Text],
346346
def execlp(path: _PathType, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> None: ...
347347
def execlpe(path: _PathType, arg0: Union[bytes, Text],
348348
*args: Any) -> None: ... # Imprecise signature
349-
def execv(path: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]]) -> None: ...
350-
def execve(path: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]], env: Mapping[str, str]) -> None: ...
351-
def execvp(file: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]]) -> None: ...
352-
def execvpe(file: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]], env: Mapping[str, str]) -> None: ...
349+
350+
# The docs say `args: tuple or list of strings`
351+
# The implementation enforces tuple or list so we can't use Sequence.
352+
_ExecVArgs = Union[Tuple[Union[bytes, Text], ...], List[bytes], List[Text], List[Union[bytes, Text]]]
353+
def execv(path: _PathType, args: _ExecVArgs) -> None: ...
354+
def execve(path: _PathType, args: _ExecVArgs, env: Mapping[str, str]) -> None: ...
355+
def execvp(file: _PathType, args: _ExecVArgs) -> None: ...
356+
def execvpe(file: _PathType, args: _ExecVArgs, env: Mapping[str, str]) -> None: ...
357+
353358
def _exit(n: int) -> NoReturn: ...
354359
def fork() -> int: ... # Unix only
355360
def forkpty() -> Tuple[int, int]: ... # some flavors of Unix

0 commit comments

Comments
 (0)