From 2d3635f10d17da5fc4a4c93856037ea78f9f1e86 Mon Sep 17 00:00:00 2001 From: Shantanu Date: Sat, 7 Mar 2020 03:59:55 -0800 Subject: [PATCH] os: fix platform availability (#3832) --- stdlib/3/os/__init__.pyi | 57 +++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/stdlib/3/os/__init__.pyi b/stdlib/3/os/__init__.pyi index 98042733e..7e8eab6dc 100644 --- a/stdlib/3/os/__init__.pyi +++ b/stdlib/3/os/__init__.pyi @@ -35,20 +35,22 @@ if sys.platform != 'win32': F_ULOCK: int F_TEST: int - POSIX_FADV_NORMAL: int - POSIX_FADV_SEQUENTIAL: int - POSIX_FADV_RANDOM: int - POSIX_FADV_NOREUSE: int - POSIX_FADV_WILLNEED: int - POSIX_FADV_DONTNEED: int + if sys.platform != "darwin": + POSIX_FADV_NORMAL: int + POSIX_FADV_SEQUENTIAL: int + POSIX_FADV_RANDOM: int + POSIX_FADV_NOREUSE: int + POSIX_FADV_WILLNEED: int + POSIX_FADV_DONTNEED: int SF_NODISKIO: int SF_MNOWAIT: int SF_SYNC: int - XATTR_SIZE_MAX: int # Linux only - XATTR_CREATE: int # Linux only - XATTR_REPLACE: int # Linux only + if sys.platform == "linux": + XATTR_SIZE_MAX: int + XATTR_CREATE: int + XATTR_REPLACE: int P_PID: int P_PGID: int @@ -338,8 +340,9 @@ if sys.platform != 'win32': def getpgrp() -> int: ... def getpriority(which: int, who: int) -> int: ... def setpriority(which: int, who: int, priority: int) -> None: ... - def getresuid() -> Tuple[int, int, int]: ... - def getresgid() -> Tuple[int, int, int]: ... + if sys.platform != "darwin": + def getresuid() -> Tuple[int, int, int]: ... + def getresgid() -> Tuple[int, int, int]: ... def getuid() -> int: ... def setegid(__egid: int) -> None: ... def seteuid(__euid: int) -> None: ... @@ -348,8 +351,9 @@ if sys.platform != 'win32': def setpgrp() -> None: ... def setpgid(__pid: int, __pgrp: int) -> None: ... def setregid(__rgid: int, __egid: int) -> None: ... - def setresgid(rgid: int, egid: int, sgid: int) -> None: ... - def setresuid(ruid: int, euid: int, suid: int) -> None: ... + if sys.platform != "darwin": + def setresgid(rgid: int, egid: int, sgid: int) -> None: ... + def setresuid(ruid: int, euid: int, suid: int) -> None: ... def setreuid(__ruid: int, __euid: int) -> None: ... def getsid(__pid: int) -> int: ... def setsid() -> None: ... @@ -390,7 +394,8 @@ if sys.platform != 'win32': # Unix only def fchmod(fd: int, mode: int) -> None: ... def fchown(fd: int, uid: int, gid: int) -> None: ... - def fdatasync(fd: int) -> None: ... # Unix only, not Mac + if sys.platform != "darwin": + def fdatasync(fd: int) -> None: ... # Unix only, not Mac def fpathconf(__fd: int, __name: Union[str, int]) -> int: ... def fstatvfs(__fd: int) -> statvfs_result: ... def ftruncate(__fd: int, __length: int) -> None: ... @@ -399,9 +404,10 @@ if sys.platform != 'win32': def isatty(__fd: int) -> bool: ... def lockf(__fd: int, __command: int, __length: int) -> None: ... def openpty() -> Tuple[int, int]: ... # some flavors of Unix - def pipe2(flags: int) -> Tuple[int, int]: ... # some flavors of Unix - def posix_fallocate(fd: int, offset: int, length: int) -> None: ... - def posix_fadvise(fd: int, offset: int, length: int, advice: int) -> None: ... + if sys.platform != "darwin": + def pipe2(flags: int) -> Tuple[int, int]: ... # some flavors of Unix + def posix_fallocate(fd: int, offset: int, length: int) -> None: ... + def posix_fadvise(fd: int, offset: int, length: int, advice: int) -> None: ... def pread(__fd: int, __length: int, __offset: int) -> bytes: ... def pwrite(__fd: int, __buffer: bytes, __offset: int) -> int: ... @overload @@ -558,11 +564,12 @@ if sys.platform != 'win32': def fwalk(top: str = ..., topdown: bool = ..., onerror: Optional[_OnError] = ..., *, follow_symlinks: bool = ..., dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ... - def getxattr(path: _FdOrPathType, attribute: _PathType, *, follow_symlinks: bool = ...) -> bytes: ... # Linux only - def listxattr(path: _FdOrPathType, *, follow_symlinks: bool = ...) -> List[str]: ... # Linux only - def removexattr(path: _FdOrPathType, attribute: _PathType, *, follow_symlinks: bool = ...) -> None: ... # Linux only - def setxattr(path: _FdOrPathType, attribute: _PathType, value: bytes, flags: int = ..., *, - follow_symlinks: bool = ...) -> None: ... # Linux only + if sys.platform == "linux": + def getxattr(path: _FdOrPathType, attribute: _PathType, *, follow_symlinks: bool = ...) -> bytes: ... + def listxattr(path: _FdOrPathType, *, follow_symlinks: bool = ...) -> List[str]: ... + def removexattr(path: _FdOrPathType, attribute: _PathType, *, follow_symlinks: bool = ...) -> None: ... + def setxattr(path: _FdOrPathType, attribute: _PathType, value: bytes, flags: int = ..., *, + follow_symlinks: bool = ...) -> None: ... def abort() -> NoReturn: ... # These are defined as execl(file, *args) but the first *arg is mandatory. @@ -590,7 +597,8 @@ if sys.platform != 'win32': def forkpty() -> Tuple[int, int]: ... # some flavors of Unix def killpg(__pgid: int, __signal: int) -> None: ... def nice(__increment: int) -> int: ... - def plock(op: int) -> None: ... # ???op is int? + if sys.platform != "darwin": + def plock(op: int) -> None: ... # ???op is int? class _wrap_close(_TextIOWrapper): def close(self) -> Optional[int]: ... # type: ignore @@ -648,7 +656,8 @@ if sys.platform != 'win32': def getloadavg() -> Tuple[float, float, float]: ... def sysconf(__name: Union[str, int]) -> int: ... if sys.version_info >= (3, 6): - def getrandom(size: int, flags: int = ...) -> bytes: ... + if sys.platform == "linux": + def getrandom(size: int, flags: int = ...) -> bytes: ... def urandom(__size: int) -> bytes: ... if sys.version_info >= (3, 7):