From 08ac3b7742f1fd55f801ac66d7517cf60aa471d6 Mon Sep 17 00:00:00 2001 From: Alvaro Caceres Date: Wed, 12 Oct 2016 09:34:35 -0500 Subject: [PATCH] 2.7/os: remove exception throwing, add misc members (#591) * 2.7/os: remove exception throwing, add misc members * added tempnam, tmpnam --- stdlib/2.7/os/__init__.pyi | 51 ++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/stdlib/2.7/os/__init__.pyi b/stdlib/2.7/os/__init__.pyi index 40f5ed0a2..ce6e6b351 100644 --- a/stdlib/2.7/os/__init__.pyi +++ b/stdlib/2.7/os/__init__.pyi @@ -2,7 +2,7 @@ from typing import ( List, Tuple, Union, Sequence, Mapping, IO, Any, Optional, AnyStr, Iterator, - MutableMapping, NamedTuple + MutableMapping, NamedTuple, overload ) from os import path @@ -50,8 +50,7 @@ def getsid(pid: int) -> int: ... def setsid() -> None: ... def setuid(pid: int) -> None: ... -def strerror(code: int) -> str: - raise ValueError() +def strerror(code: int) -> str: ... def umask(mask: int) -> int: ... def uname() -> Tuple[str, str, str, str, str]: ... @@ -62,6 +61,9 @@ def fdopen(fd: int, *args, **kwargs) -> IO[Any]: ... def popen(command: str, *args, **kwargs) -> Optional[IO[Any]]: ... def tmpfile() -> IO[Any]: ... +def tmpnam() -> str: ... +def tempnam(dir: str = ..., prefix: str = ...) -> str: ... + def popen2(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any]]: ... def popen3(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any], IO[Any]]: ... def popen4(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any]]: ... @@ -131,8 +133,7 @@ pathconf_names = ... # type: Mapping[str, int] def readlink(path: AnyStr) -> AnyStr: ... def remove(path: unicode) -> None: ... -def removedirs(path: unicode) -> None: - raise OSError() +def removedirs(path: unicode) -> None: ... def rename(src: unicode, dst: unicode) -> None: ... def renames(old: unicode, new: unicode) -> None: ... def rmdir(path: unicode) -> None: ... @@ -148,7 +149,6 @@ _StatVFS = NamedTuple('_StatVFS', [('f_bsize', int), ('f_frsize', int), ('f_bloc def fstatvfs(fd: int) -> _StatVFS: ... def statvfs(path: unicode) -> _StatVFS: ... -# TODO: stat_float_times, tempnam, tmpnam, TMP_MAX def walk(top: AnyStr, topdown: bool = ..., onerror: Any = ..., followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... @@ -187,11 +187,8 @@ def execve(path: AnyStr, args: Union[Tuple[AnyStr], List[AnyStr]], env: Mapping[ def _exit(n: int) -> None: ... -def fork() -> int: - raise OSError() - -def forkpty() -> Tuple[int, int]: - raise OSError() +def fork() -> int: ... +def forkpty() -> Tuple[int, int]: ... def kill(pid: int, sig: int) -> None: ... def killpg(pgid: int, sig: int) -> None: ... @@ -217,14 +214,14 @@ def startfile(path: unicode, operation: str = ...) -> None: ... # Windows only def system(command: unicode) -> int: ... def times() -> Tuple[float, float, float, float, float]: ... def wait() -> Tuple[int, int]: ... # Unix only -def waitpid(pid: int, options: int) -> Tuple[int, int]: - raise OSError() -# TODO: wait3, wait4, W... +def wait3(options: int) -> Tuple[int, int, Any]: ... # Unix only +def wait4(pid: int, options: int) -> Tuple[int, int, Any]: ... # Unix only +def waitpid(pid: int, options: int) -> Tuple[int, int]: ... + def confstr(name: Union[str, int]) -> Optional[str]: ... confstr_names = ... # type: Mapping[str, int] -def getloadavg() -> Tuple[float, float, float]: - raise OSError() +def getloadavg() -> Tuple[float, float, float]: ... def sysconf(name: Union[str, int]) -> int: ... sysconf_names = ... # type: Mapping[str, int] @@ -270,6 +267,7 @@ O_DIRECT = 0 # Gnu extension if in C library O_DIRECTORY = 0 # Gnu extension if in C library O_NOFOLLOW = 0 # Gnu extension if in C library O_NOATIME = 0 # Gnu extension if in C library +O_LARGEFILE = 0 # Gnu extension if in C library P_NOWAIT = 0 P_NOWAITO = 0 @@ -279,9 +277,26 @@ P_WAIT = 0 # wait()/waitpid() options WNOHANG = 0 # Unix only -#WCONTINUED = 0 # some Unix systems -#WUNTRACED = 0 # Unix only +WCONTINUED = 0 # some Unix systems +WUNTRACED = 0 # Unix only P_ALL = 0 WEXITED = 0 WNOWAIT = 0 + +TMP_MAX = 0 + +# Below are Unix-only +def WCOREDUMP(status: int) -> bool: ... +def WEXITSTATUS(status: int) -> int: ... +def WIFCONTINUED(status: int) -> bool: ... +def WIFEXITED(status: int) -> bool: ... +def WIFSIGNALED(status: int) -> bool: ... +def WIFSTOPPED(status: int) -> bool: ... +def WSTOPSIG(status: int) -> int: ... +def WTERMSIG(status: int) -> int: ... + +@overload +def stat_float_times(newvalue: bool = ...) -> None: ... +@overload +def stat_float_times() -> bool: ...