Add various missing os constants (#6753)

This commit is contained in:
Alex Waygood
2021-12-30 13:21:30 +00:00
committed by GitHub
parent 6ca1dad2a2
commit 496313d875
10 changed files with 48 additions and 96 deletions

View File

@@ -90,6 +90,9 @@ if sys.platform != "win32":
P_PGID: int
P_ALL: int
if sys.platform == "linux" and sys.version_info >= (3, 9):
P_PIDFD: int
WEXITED: int
WSTOPPED: int
WNOWAIT: int
@@ -99,6 +102,10 @@ if sys.platform != "win32":
CLD_TRAPPED: int
CLD_CONTINUED: int
if sys.version_info >= (3, 9):
CLD_KILLED: int
CLD_STOPPED: int
# TODO: SCHED_RESET_ON_FORK not available on darwin?
# TODO: SCHED_BATCH and SCHED_IDLE are linux only?
SCHED_OTHER: int # some flavors of Unix
@@ -173,14 +180,14 @@ if sys.platform != "win32" and sys.platform != "darwin":
ST_NODEV: int
ST_NODIRATIME: int
ST_NOEXEC: int
ST_NOSUID: int
ST_RDONLY: int
ST_RELATIME: int
ST_SYNCHRONOUS: int
ST_WRITE: int
if sys.platform != "win32":
NGROUPS_MAX: int
ST_NOSUID: int
ST_RDONLY: int
curdir: str
pardir: str
@@ -621,6 +628,16 @@ if sys.platform != "win32":
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: ...
if sys.platform != "darwin":
if sys.version_info >= (3, 10):
RWF_APPEND: int # docs say available on 3.7+, stubtest says otherwise
if sys.version_info >= (3, 7):
def preadv(__fd: int, __buffers: Iterable[bytes], __offset: int, __flags: int = ...) -> int: ...
def pwritev(__fd: int, __buffers: Iterable[bytes], __offset: int, __flags: int = ...) -> int: ...
RWF_DSYNC: int
RWF_SYNC: int
RWF_HIPRI: int
RWF_NOWAIT: int
@overload
def sendfile(out_fd: int, in_fd: int, offset: int | None, count: int) -> int: ...
@overload
@@ -931,6 +948,9 @@ else:
setsigdef: Iterable[int] = ...,
scheduler: tuple[Any, sched_param] | None = ...,
) -> int: ...
POSIX_SPAWN_OPEN: int
POSIX_SPAWN_CLOSE: int
POSIX_SPAWN_DUP2: int
if sys.platform != "win32":
@final

View File

@@ -70,6 +70,8 @@ if sys.platform != "win32":
SCHED_SPORADIC as SCHED_SPORADIC,
SEEK_DATA as SEEK_DATA,
SEEK_HOLE as SEEK_HOLE,
ST_NOSUID as ST_NOSUID,
ST_RDONLY as ST_RDONLY,
TMP_MAX as TMP_MAX,
W_OK as W_OK,
WCONTINUED as WCONTINUED,
@@ -264,10 +266,22 @@ if sys.platform != "win32":
waitid_result as waitid_result,
)
if sys.version_info >= (3, 10):
from os import RWF_APPEND as RWF_APPEND
if sys.version_info >= (3, 9):
from os import waitstatus_to_exitcode as waitstatus_to_exitcode
from os import CLD_KILLED as CLD_KILLED, CLD_STOPPED as CLD_STOPPED, waitstatus_to_exitcode as waitstatus_to_exitcode
if sys.platform == "linux":
from os import P_PIDFD as P_PIDFD
if sys.version_info >= (3, 8):
from os import posix_spawn as posix_spawn, posix_spawnp as posix_spawnp
from os import (
POSIX_SPAWN_CLOSE as POSIX_SPAWN_CLOSE,
POSIX_SPAWN_DUP2 as POSIX_SPAWN_DUP2,
POSIX_SPAWN_OPEN as POSIX_SPAWN_OPEN,
posix_spawn as posix_spawn,
posix_spawnp as posix_spawnp,
)
if sys.platform == "linux":
from os import (
@@ -293,6 +307,16 @@ if sys.platform != "win32":
if sys.version_info >= (3, 7):
from os import register_at_fork as register_at_fork
if sys.platform != "darwin":
from os import (
RWF_DSYNC as RWF_DSYNC,
RWF_HIPRI as RWF_HIPRI,
RWF_NOWAIT as RWF_NOWAIT,
RWF_SYNC as RWF_SYNC,
preadv as preadv,
pwritev as pwritev,
)
# Not same as os.environ or os.environb
# Because of this variable, we can't do "from posix import *" in os/__init__.pyi
environ: dict[bytes, bytes]

View File

@@ -5,15 +5,4 @@ curses.color_pair
# Exists at runtime, but missing from stubs
asyncio.PidfdChildWatcher
asyncio.unix_events.PidfdChildWatcher
os.CLD_KILLED
os.CLD_STOPPED
os.POSIX_SPAWN_CLOSE
os.POSIX_SPAWN_DUP2
os.POSIX_SPAWN_OPEN
mmap.MADV_FREE
posix.CLD_KILLED
posix.CLD_STOPPED
posix.POSIX_SPAWN_CLOSE
posix.POSIX_SPAWN_DUP2
posix.POSIX_SPAWN_OPEN

View File

@@ -1,11 +1,4 @@
_?curses.A_ITALIC
# Exists at runtime, but missing from stubs
os.POSIX_SPAWN_CLOSE
os.POSIX_SPAWN_DUP2
os.POSIX_SPAWN_OPEN
mmap.MADV_FREE
posix.POSIX_SPAWN_CLOSE
posix.POSIX_SPAWN_DUP2
posix.POSIX_SPAWN_OPEN

View File

@@ -3,15 +3,4 @@ _?curses.A_ITALIC
# Exists at runtime, but missing from stubs
asyncio.PidfdChildWatcher
asyncio.unix_events.PidfdChildWatcher
os.CLD_KILLED
os.CLD_STOPPED
os.POSIX_SPAWN_CLOSE
os.POSIX_SPAWN_DUP2
os.POSIX_SPAWN_OPEN
mmap.MADV_FREE
posix.CLD_KILLED
posix.CLD_STOPPED
posix.POSIX_SPAWN_CLOSE
posix.POSIX_SPAWN_DUP2
posix.POSIX_SPAWN_OPEN

View File

@@ -46,8 +46,6 @@ distutils.msvccompiler.MSVCCompiler.get_msvc_paths
distutils.msvccompiler.MSVCCompiler.set_path_env_var
distutils.msvccompiler.MacroExpander
mimetypes.MimeTypes.read_windows_registry
os.ST_NOSUID
os.ST_RDONLY
selectors.DefaultSelector.fileno
socket.AddressInfo.AI_DEFAULT
socket.AddressInfo.AI_MASK

View File

@@ -21,20 +21,9 @@ select.epoll.register
asyncio.PidfdChildWatcher
asyncio.unix_events.PidfdChildWatcher
mmap.MAP_POPULATE
os.CLD_KILLED
os.CLD_STOPPED
os.EFD_CLOEXEC
os.EFD_NONBLOCK
os.EFD_SEMAPHORE
os.POSIX_SPAWN_CLOSE
os.POSIX_SPAWN_DUP2
os.POSIX_SPAWN_OPEN
os.P_PIDFD
os.RWF_APPEND
os.RWF_DSYNC
os.RWF_HIPRI
os.RWF_NOWAIT
os.RWF_SYNC
os.SPLICE_F_MORE
os.SPLICE_F_MOVE
os.SPLICE_F_NONBLOCK
@@ -43,22 +32,13 @@ os.eventfd
os.eventfd_read
os.eventfd_write
os.pidfd_open
os.preadv
os.pwritev
os.splice
posix.CLD_KILLED
posix.CLD_STOPPED
posix.EFD_[A-Z]+
posix.P_PIDFD
posix.POSIX_SPAWN_[A-Z0-9]+
posix.RWF_[A-Z]+
posix.SPLICE_[A-Z_]+
posix.copy_file_range
posix.eventfd
posix.eventfd_read
posix.eventfd_write
posix.pidfd_open
posix.preadv
posix.pwritev
posix.splice
time.pthread_getcpuclockid

View File

@@ -3,13 +3,4 @@ ftplib.FTP.trust_server_pasv_ipv4_address # Dangerous to use, intentionally und
pwd.getpwnam
# Exists at runtime, but missing from stubs
os.RWF_DSYNC
os.RWF_HIPRI
os.RWF_NOWAIT
os.RWF_SYNC
os.preadv
os.pwritev
posix.RWF_[A-Z]+
posix.preadv
posix.pwritev
time.pthread_getcpuclockid

View File

@@ -1,19 +1,6 @@
select.epoll.register
# Exists at runtime, but missing from stubs
os.POSIX_SPAWN_CLOSE
os.POSIX_SPAWN_DUP2
os.POSIX_SPAWN_OPEN
os.RWF_DSYNC
os.RWF_HIPRI
os.RWF_NOWAIT
os.RWF_SYNC
os.copy_file_range
os.preadv
os.pwritev
posix.POSIX_SPAWN_[A-Z0-9]+
posix.RWF_[A-Z]+
posix.copy_file_range
posix.preadv
posix.pwritev
time.pthread_getcpuclockid

View File

@@ -4,27 +4,8 @@ select.epoll.register
# Exists at runtime, but missing from stubs
asyncio.PidfdChildWatcher
asyncio.unix_events.PidfdChildWatcher
os.CLD_KILLED
os.CLD_STOPPED
os.POSIX_SPAWN_CLOSE
os.POSIX_SPAWN_DUP2
os.POSIX_SPAWN_OPEN
os.P_PIDFD
os.RWF_DSYNC
os.RWF_HIPRI
os.RWF_NOWAIT
os.RWF_SYNC
os.copy_file_range
os.pidfd_open
os.preadv
os.pwritev
posix.CLD_KILLED
posix.CLD_STOPPED
posix.P_PIDFD
posix.POSIX_SPAWN_[A-Z0-9]+
posix.RWF_[A-Z]+
posix.copy_file_range
posix.pidfd_open
posix.preadv
posix.pwritev
time.pthread_getcpuclockid