diff --git a/stdlib/posix.pyi b/stdlib/posix.pyi index 08b55d10a..21af3c2d2 100644 --- a/stdlib/posix.pyi +++ b/stdlib/posix.pyi @@ -87,10 +87,134 @@ if sys.platform != "win32": WTERMSIG as WTERMSIG, WUNTRACED as WUNTRACED, X_OK as X_OK, + DirEntry as DirEntry, + _exit as _exit, + abort as abort, + access as access, + chdir as chdir, + chmod as chmod, + chown as chown, + chroot as chroot, + close as close, + closerange as closerange, + confstr as confstr, + confstr_names as confstr_names, + cpu_count as cpu_count, + ctermid as ctermid, + device_encoding as device_encoding, + dup as dup, + error as error, + execv as execv, + execve as execve, + fchdir as fchdir, + fchmod as fchmod, + fchown as fchown, + fork as fork, + forkpty as forkpty, + fpathconf as fpathconf, + fspath as fspath, + fstat as fstat, + fstatvfs as fstatvfs, + fsync as fsync, + ftruncate as ftruncate, + get_blocking as get_blocking, + get_inheritable as get_inheritable, + get_terminal_size as get_terminal_size, + getcwd as getcwd, + getcwdb as getcwdb, + getegid as getegid, + geteuid as geteuid, + getgid as getgid, + getgrouplist as getgrouplist, + getgroups as getgroups, + getloadavg as getloadavg, + getlogin as getlogin, + getpgid as getpgid, + getpgrp as getpgrp, + getpid as getpid, + getppid as getppid, + getpriority as getpriority, + getsid as getsid, + getuid as getuid, + initgroups as initgroups, + isatty as isatty, + kill as kill, + killpg as killpg, + lchown as lchown, + link as link, listdir as listdir, + lockf as lockf, + lseek as lseek, + lstat as lstat, + major as major, + makedev as makedev, + minor as minor, + mkdir as mkdir, + mkfifo as mkfifo, + mknod as mknod, + nice as nice, + open as open, + openpty as openpty, + pathconf as pathconf, + pathconf_names as pathconf_names, + pipe as pipe, + pread as pread, + putenv as putenv, + pwrite as pwrite, + read as read, + readlink as readlink, + readv as readv, + remove as remove, + rename as rename, + replace as replace, + rmdir as rmdir, + scandir as scandir, + sched_get_priority_max as sched_get_priority_max, + sched_get_priority_min as sched_get_priority_min, + sched_param as sched_param, + sched_yield as sched_yield, + sendfile as sendfile, + set_blocking as set_blocking, + set_inheritable as set_inheritable, + setegid as setegid, + seteuid as seteuid, + setgid as setgid, + setgroups as setgroups, + setpgid as setpgid, + setpgrp as setpgrp, + setpriority as setpriority, + setregid as setregid, + setreuid as setreuid, + setsid as setsid, + setuid as setuid, + stat as stat, stat_result as stat_result, + statvfs as statvfs, + statvfs_result as statvfs_result, + strerror as strerror, + symlink as symlink, + sync as sync, + sysconf as sysconf, + sysconf_names as sysconf_names, + system as system, + tcgetpgrp as tcgetpgrp, + tcsetpgrp as tcsetpgrp, + terminal_size as terminal_size, + times as times, times_result as times_result, + truncate as truncate, + ttyname as ttyname, + umask as umask, + uname as uname, uname_result as uname_result, + unlink as unlink, + unsetenv as unsetenv, + urandom as urandom, + utime as utime, + wait as wait, + waitpid as waitpid, + write as write, + writev as writev, ) if sys.platform == "linux": @@ -101,6 +225,11 @@ if sys.platform != "win32": XATTR_CREATE as XATTR_CREATE, XATTR_REPLACE as XATTR_REPLACE, XATTR_SIZE_MAX as XATTR_SIZE_MAX, + getrandom as getrandom, + getxattr as getxattr, + listxattr as listxattr, + removexattr as removexattr, + setxattr as setxattr, ) if sys.platform != "darwin": from os import ( @@ -110,11 +239,53 @@ if sys.platform != "win32": POSIX_FADV_RANDOM as POSIX_FADV_RANDOM, POSIX_FADV_SEQUENTIAL as POSIX_FADV_SEQUENTIAL, POSIX_FADV_WILLNEED as POSIX_FADV_WILLNEED, + fdatasync as fdatasync, + getresgid as getresgid, + getresuid as getresuid, + posix_fadvise as posix_fadvise, + posix_fallocate as posix_fallocate, + sched_getaffinity as sched_getaffinity, + sched_getparam as sched_getparam, + sched_getscheduler as sched_getscheduler, + sched_rr_get_interval as sched_rr_get_interval, + sched_setaffinity as sched_setaffinity, + sched_setparam as sched_setparam, + sched_setscheduler as sched_setscheduler, + setresgid as setresgid, + setresuid as setresuid, + waitid as waitid, + waitid_result as waitid_result, ) + if sys.version_info >= (3, 9): + from os import waitstatus_to_exitcode as waitstatus_to_exitcode if sys.version_info >= (3, 8): from os import posix_spawn as posix_spawn, posix_spawnp as posix_spawnp + if sys.platform == "linux": + from os import ( + MFD_ALLOW_SEALING as MFD_ALLOW_SEALING, + MFD_CLOEXEC as MFD_CLOEXEC, + MFD_HUGE_1GB as MFD_HUGE_1GB, + MFD_HUGE_1MB as MFD_HUGE_1MB, + MFD_HUGE_2GB as MFD_HUGE_2GB, + MFD_HUGE_2MB as MFD_HUGE_2MB, + MFD_HUGE_8MB as MFD_HUGE_8MB, + MFD_HUGE_16GB as MFD_HUGE_16GB, + MFD_HUGE_16MB as MFD_HUGE_16MB, + MFD_HUGE_32MB as MFD_HUGE_32MB, + MFD_HUGE_64KB as MFD_HUGE_64KB, + MFD_HUGE_256MB as MFD_HUGE_256MB, + MFD_HUGE_512KB as MFD_HUGE_512KB, + MFD_HUGE_512MB as MFD_HUGE_512MB, + MFD_HUGE_MASK as MFD_HUGE_MASK, + MFD_HUGE_SHIFT as MFD_HUGE_SHIFT, + MFD_HUGETLB as MFD_HUGETLB, + memfd_create as memfd_create, + ) + if sys.version_info >= (3, 7): + from os import register_at_fork as register_at_fork + # 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] diff --git a/tests/stubtest_allowlists/darwin-py310.txt b/tests/stubtest_allowlists/darwin-py310.txt index c44779c75..10ce26026 100644 --- a/tests/stubtest_allowlists/darwin-py310.txt +++ b/tests/stubtest_allowlists/darwin-py310.txt @@ -14,5 +14,3 @@ os.CLD_STOPPED os.POSIX_SPAWN_CLOSE os.POSIX_SPAWN_DUP2 os.POSIX_SPAWN_OPEN -posix.register_at_fork -posix.waitstatus_to_exitcode diff --git a/tests/stubtest_allowlists/darwin-py37.txt b/tests/stubtest_allowlists/darwin-py37.txt index 41485ea2d..8c6d33126 100644 --- a/tests/stubtest_allowlists/darwin-py37.txt +++ b/tests/stubtest_allowlists/darwin-py37.txt @@ -4,4 +4,3 @@ pwd.getpwnam # Exists at runtime, but missing from stubs ftplib.FTP.trust_server_pasv_ipv4_address -posix.register_at_fork diff --git a/tests/stubtest_allowlists/darwin-py38.txt b/tests/stubtest_allowlists/darwin-py38.txt index b99d18e0f..da34281ca 100644 --- a/tests/stubtest_allowlists/darwin-py38.txt +++ b/tests/stubtest_allowlists/darwin-py38.txt @@ -4,4 +4,3 @@ _?curses.A_ITALIC os.POSIX_SPAWN_CLOSE os.POSIX_SPAWN_DUP2 os.POSIX_SPAWN_OPEN -posix.register_at_fork diff --git a/tests/stubtest_allowlists/darwin-py39.txt b/tests/stubtest_allowlists/darwin-py39.txt index be7a1000f..1a75d252c 100644 --- a/tests/stubtest_allowlists/darwin-py39.txt +++ b/tests/stubtest_allowlists/darwin-py39.txt @@ -12,5 +12,3 @@ os.CLD_STOPPED os.POSIX_SPAWN_CLOSE os.POSIX_SPAWN_DUP2 os.POSIX_SPAWN_OPEN -posix.register_at_fork -posix.waitstatus_to_exitcode diff --git a/tests/stubtest_allowlists/darwin.txt b/tests/stubtest_allowlists/darwin.txt index 26c126d12..72e3a0977 100644 --- a/tests/stubtest_allowlists/darwin.txt +++ b/tests/stubtest_allowlists/darwin.txt @@ -12,7 +12,7 @@ os.EX_NOTFOUND os.SF_MNOWAIT os.SF_NODISKIO os.SF_SYNC -os.sched_param # system dependent. Unclear if macos has it. +(os|posix).sched_param # system dependent. Unclear if macos has it. posix.EX_NOTFOUND readline.append_history_file # not defined in macos select.KQ_FILTER_NETDEV # system dependent @@ -57,140 +57,15 @@ grp.struct_group.n_unnamed_fields mimetypes.MimeTypes.read_windows_registry os.ST_NOSUID os.ST_RDONLY -os.uname_result.n_fields -os.uname_result.n_sequence_fields -os.uname_result.n_unnamed_fields -posix.DirEntry -posix.abort -posix.access -posix.chdir +(os|posix).uname_result.n_fields +(os|posix).uname_result.n_sequence_fields +(os|posix).uname_result.n_unnamed_fields posix.chflags -posix.chmod -posix.chown -posix.chroot -posix.close -posix.closerange -posix.confstr -posix.cpu_count -posix.ctermid -posix.device_encoding -posix.dup posix.dup2 -posix.execv -posix.execve -posix.fchdir -posix.fchmod -posix.fchown -posix.fork -posix.forkpty -posix.fpathconf -posix.fspath -posix.fstat -posix.fstatvfs -posix.fsync -posix.ftruncate -posix.get_blocking -posix.get_inheritable -posix.get_terminal_size -posix.getcwd -posix.getcwdb -posix.getegid -posix.geteuid -posix.getgid -posix.getgrouplist -posix.getgroups -posix.getloadavg -posix.getlogin -posix.getpgid -posix.getpgrp -posix.getpid -posix.getppid -posix.getpriority -posix.getsid -posix.getuid -posix.initgroups -posix.isatty -posix.kill -posix.killpg posix.lchflags posix.lchmod -posix.lchown -posix.link -posix.lockf -posix.lseek -posix.lstat -posix.major -posix.makedev -posix.minor -posix.mkdir -posix.mkfifo -posix.mknod -posix.nice -posix.open -posix.openpty -posix.pathconf -posix.pipe -posix.pread -posix.putenv -posix.pwrite -posix.read -posix.readlink -posix.readv -posix.remove -posix.rename -posix.replace -posix.rmdir -posix.scandir -posix.sched_get_priority_max -posix.sched_get_priority_min -posix.sched_yield -posix.sendfile -posix.set_blocking -posix.set_inheritable -posix.setegid -posix.seteuid -posix.setgid -posix.setgroups -posix.setpgid -posix.setpgrp -posix.setpriority -posix.setregid -posix.setreuid -posix.setsid -posix.setuid -posix.stat -posix.stat_result.n_fields -posix.stat_result.n_sequence_fields -posix.stat_result.n_unnamed_fields -posix.statvfs -posix.strerror -posix.symlink -posix.sync -posix.sysconf -posix.system -posix.tcgetpgrp -posix.tcsetpgrp -posix.times -posix.times_result.n_fields -posix.times_result.n_sequence_fields -posix.times_result.n_unnamed_fields -posix.truncate -posix.ttyname -posix.umask -posix.uname -posix.uname_result.n_fields -posix.uname_result.n_sequence_fields -posix.uname_result.n_unnamed_fields -posix.unlink -posix.unsetenv -posix.urandom -posix.utime -posix.wait posix.wait3 posix.wait4 -posix.waitpid -posix.write -posix.writev resource.struct_rusage.n_fields resource.struct_rusage.n_sequence_fields resource.struct_rusage.n_unnamed_fields diff --git a/tests/stubtest_allowlists/linux-py310.txt b/tests/stubtest_allowlists/linux-py310.txt index ac90ff849..b02c93538 100644 --- a/tests/stubtest_allowlists/linux-py310.txt +++ b/tests/stubtest_allowlists/linux-py310.txt @@ -1,19 +1,19 @@ _curses.color_pair curses.color_pair os.pipe2 -os.posix_fadvise -os.posix_fallocate -os.sched_getaffinity -os.sched_getparam -os.sched_getscheduler -os.sched_rr_get_interval -os.sched_setaffinity -os.sched_setparam -os.sched_setscheduler -os.setresgid -os.setresuid -os.waitid -os.sendfile +(os|posix).posix_fadvise +(os|posix).posix_fallocate +(os|posix).sched_getaffinity +(os|posix).sched_getparam +(os|posix).sched_getscheduler +(os|posix).sched_rr_get_interval +(os|posix).sched_setaffinity +(os|posix).sched_setparam +(os|posix).sched_setscheduler +(os|posix).setresgid +(os|posix).setresuid +(os|posix).waitid +(os|posix).sendfile signal.sigtimedwait signal.sigwaitinfo select.epoll.register @@ -54,11 +54,8 @@ posix.copy_file_range posix.eventfd posix.eventfd_read posix.eventfd_write -posix.memfd_create posix.pidfd_open posix.preadv posix.pwritev -posix.register_at_fork posix.splice -posix.waitstatus_to_exitcode time.pthread_getcpuclockid diff --git a/tests/stubtest_allowlists/linux-py37.txt b/tests/stubtest_allowlists/linux-py37.txt index 1df53ac40..5f990bdec 100644 --- a/tests/stubtest_allowlists/linux-py37.txt +++ b/tests/stubtest_allowlists/linux-py37.txt @@ -11,5 +11,4 @@ os.preadv os.pwritev posix.preadv posix.pwritev -posix.register_at_fork time.pthread_getcpuclockid diff --git a/tests/stubtest_allowlists/linux-py38.txt b/tests/stubtest_allowlists/linux-py38.txt index 6bb2bf048..d8668f843 100644 --- a/tests/stubtest_allowlists/linux-py38.txt +++ b/tests/stubtest_allowlists/linux-py38.txt @@ -12,8 +12,6 @@ os.copy_file_range os.preadv os.pwritev posix.copy_file_range -posix.memfd_create posix.preadv posix.pwritev -posix.register_at_fork time.pthread_getcpuclockid diff --git a/tests/stubtest_allowlists/linux-py39.txt b/tests/stubtest_allowlists/linux-py39.txt index f85379c92..046b7923c 100644 --- a/tests/stubtest_allowlists/linux-py39.txt +++ b/tests/stubtest_allowlists/linux-py39.txt @@ -1,4 +1,4 @@ -os.sendfile +(os|posix).sendfile select.epoll.register # Exists at runtime, but missing from stubs @@ -23,10 +23,7 @@ os.pidfd_open os.preadv os.pwritev posix.copy_file_range -posix.memfd_create posix.pidfd_open posix.preadv posix.pwritev -posix.register_at_fork -posix.waitstatus_to_exitcode time.pthread_getcpuclockid diff --git a/tests/stubtest_allowlists/linux.txt b/tests/stubtest_allowlists/linux.txt index 9fc8c5ee7..57b2e6f01 100644 --- a/tests/stubtest_allowlists/linux.txt +++ b/tests/stubtest_allowlists/linux.txt @@ -59,166 +59,19 @@ grp.struct_group.n_fields grp.struct_group.n_sequence_fields grp.struct_group.n_unnamed_fields mimetypes.MimeTypes.read_windows_registry -os.sched_param.n_fields -os.sched_param.n_sequence_fields -os.sched_param.n_unnamed_fields -os.uname_result.n_fields -os.uname_result.n_sequence_fields -os.uname_result.n_unnamed_fields -os.waitid_result.n_fields -os.waitid_result.n_sequence_fields -os.waitid_result.n_unnamed_fields -posix.DirEntry -posix.abort -posix.access -posix.chdir -posix.chmod -posix.chown -posix.chroot -posix.close -posix.closerange -posix.confstr -posix.cpu_count -posix.ctermid -posix.device_encoding -posix.dup +(os|posix).sched_param.n_fields +(os|posix).sched_param.n_sequence_fields +(os|posix).sched_param.n_unnamed_fields +(os|posix).uname_result.n_fields +(os|posix).uname_result.n_sequence_fields +(os|posix).uname_result.n_unnamed_fields +(os|posix).waitid_result.n_fields +(os|posix).waitid_result.n_sequence_fields +(os|posix).waitid_result.n_unnamed_fields posix.dup2 -posix.execv -posix.execve -posix.fchdir -posix.fchmod -posix.fchown -posix.fdatasync -posix.fork -posix.forkpty -posix.fpathconf -posix.fspath -posix.fstat -posix.fstatvfs -posix.fsync -posix.ftruncate -posix.get_blocking -posix.get_inheritable -posix.get_terminal_size -posix.getcwd -posix.getcwdb -posix.getegid -posix.geteuid -posix.getgid -posix.getgrouplist -posix.getgroups -posix.getloadavg -posix.getlogin -posix.getpgid -posix.getpgrp -posix.getpid -posix.getppid -posix.getpriority -posix.getrandom -posix.getresgid -posix.getresuid -posix.getsid -posix.getuid -posix.getxattr -posix.initgroups -posix.isatty -posix.kill -posix.killpg -posix.lchown -posix.link -posix.listxattr -posix.lockf -posix.lseek -posix.lstat -posix.major -posix.makedev -posix.minor -posix.mkdir -posix.mkfifo -posix.mknod -posix.nice -posix.open -posix.openpty -posix.pathconf -posix.pipe posix.pipe2 -posix.posix_fadvise -posix.posix_fallocate -posix.pread -posix.putenv -posix.pwrite -posix.read -posix.readlink -posix.readv -posix.remove -posix.removexattr -posix.rename -posix.replace -posix.rmdir -posix.scandir -posix.sched_get_priority_max -posix.sched_get_priority_min -posix.sched_getaffinity -posix.sched_getparam -posix.sched_getscheduler -posix.sched_param -posix.sched_rr_get_interval -posix.sched_setaffinity -posix.sched_setparam -posix.sched_setscheduler -posix.sched_yield -posix.sendfile -posix.set_blocking -posix.set_inheritable -posix.setegid -posix.seteuid -posix.setgid -posix.setgroups -posix.setpgid -posix.setpgrp -posix.setpriority -posix.setregid -posix.setresgid -posix.setresuid -posix.setreuid -posix.setsid -posix.setuid -posix.setxattr -posix.stat -posix.stat_result.n_fields -posix.stat_result.n_sequence_fields -posix.stat_result.n_unnamed_fields -posix.statvfs -posix.strerror -posix.symlink -posix.sync -posix.sysconf -posix.system -posix.tcgetpgrp -posix.tcsetpgrp -posix.times -posix.times_result.n_fields -posix.times_result.n_sequence_fields -posix.times_result.n_unnamed_fields -posix.truncate -posix.ttyname -posix.umask -posix.uname -posix.uname_result.n_fields -posix.uname_result.n_sequence_fields -posix.uname_result.n_unnamed_fields -posix.unlink -posix.unsetenv -posix.urandom -posix.utime -posix.wait posix.wait3 posix.wait4 -posix.waitid -posix.waitid_result -posix.waitpid -posix.write -posix.writev resource.struct_rusage.n_fields resource.struct_rusage.n_sequence_fields resource.struct_rusage.n_unnamed_fields diff --git a/tests/stubtest_allowlists/py36.txt b/tests/stubtest_allowlists/py36.txt index f78cb8983..902c675ce 100644 --- a/tests/stubtest_allowlists/py36.txt +++ b/tests/stubtest_allowlists/py36.txt @@ -31,7 +31,7 @@ ipaddress._BaseNetwork.__init__ json.loads mmap.ACCESS_DEFAULT multiprocessing.shared_memory -os.utime +(os|posix).utime plistlib.Dict.__init__ pyexpat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args random.Random.randrange # missing undocumented arg _int diff --git a/tests/stubtest_allowlists/py37.txt b/tests/stubtest_allowlists/py37.txt index fbc192665..bde35c9fc 100644 --- a/tests/stubtest_allowlists/py37.txt +++ b/tests/stubtest_allowlists/py37.txt @@ -36,7 +36,7 @@ importlib.metadata # Added in 3.8 ipaddress._BaseNetwork.__init__ json.loads multiprocessing.shared_memory -os.utime +(os|posix).utime pyexpat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args queue.SimpleQueue.__init__ # Default C __init__ signature is wrong random.Random.randrange # missing undocumented arg _int diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index b14cd8f93..820bf84af 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -571,15 +571,15 @@ multiprocessing.pool.Pool.Process multiprocessing.pool.ThreadPool.Process multiprocessing.reducer multiprocessing.synchronize.Semaphore.get_value -os.stat_result.n_fields -os.stat_result.n_sequence_fields -os.stat_result.n_unnamed_fields -os.terminal_size.n_fields -os.terminal_size.n_sequence_fields -os.terminal_size.n_unnamed_fields -os.times_result.n_fields -os.times_result.n_sequence_fields -os.times_result.n_unnamed_fields +(os|posix).stat_result.n_fields +(os|posix).stat_result.n_sequence_fields +(os|posix).stat_result.n_unnamed_fields +(os|posix).terminal_size.n_fields +(os|posix).terminal_size.n_sequence_fields +(os|posix).terminal_size.n_unnamed_fields +(os|posix).times_result.n_fields +(os|posix).times_result.n_sequence_fields +(os|posix).times_result.n_unnamed_fields pickle.Pickler.memo pickle.Unpickler.memo pipes.Template.makepipeline