diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index b658ca2a7..d0761fe89 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -2,6 +2,7 @@ import sys from _typeshed import ( AnyStr_co, BytesPath, + FileDescriptor, FileDescriptorLike, FileDescriptorOrPath, GenericPath, @@ -1057,6 +1058,14 @@ if sys.version_info >= (3, 12) and sys.platform == "win32": def listmounts(volume: str) -> list[str]: ... def listvolumes() -> list[str]: ... +if sys.version_info >= (3, 10) and sys.platform == "linux": + EFD_CLOEXEC: int + EFD_NONBLOCK: int + EFD_SEMAPHORE: int + def eventfd(initval: int, flags: int = 524288) -> FileDescriptor: ... + def eventfd_read(fd: FileDescriptor) -> int: ... + def eventfd_write(fd: FileDescriptor, value: int) -> None: ... + if sys.version_info >= (3, 12) and sys.platform == "linux": CLONE_FILES: int CLONE_FS: int @@ -1072,3 +1081,4 @@ if sys.version_info >= (3, 12) and sys.platform == "linux": CLONE_SYSVSEM: int CLONE_THREAD: int CLONE_VM: int + def unshare(flags: int) -> None: ... diff --git a/stdlib/posix.pyi b/stdlib/posix.pyi index b6803ca68..6c66c0d6a 100644 --- a/stdlib/posix.pyi +++ b/stdlib/posix.pyi @@ -236,6 +236,16 @@ if sys.platform != "win32": removexattr as removexattr, setxattr as setxattr, ) + + if sys.version_info >= (3, 10): + from os import ( + EFD_CLOEXEC as EFD_CLOEXEC, + EFD_NONBLOCK as EFD_NONBLOCK, + EFD_SEMAPHORE as EFD_SEMAPHORE, + eventfd as eventfd, + eventfd_read as eventfd_read, + eventfd_write as eventfd_write, + ) else: from os import chflags as chflags, lchflags as lchflags, lchmod as lchmod @@ -330,6 +340,7 @@ if sys.platform != "win32": CLONE_SYSVSEM as CLONE_SYSVSEM, CLONE_THREAD as CLONE_THREAD, CLONE_VM as CLONE_VM, + unshare as unshare, ) # Not same as os.environ or os.environb diff --git a/tests/stubtest_allowlists/linux-py310.txt b/tests/stubtest_allowlists/linux-py310.txt index 77058e51e..7c8f906da 100644 --- a/tests/stubtest_allowlists/linux-py310.txt +++ b/tests/stubtest_allowlists/linux-py310.txt @@ -1,16 +1,10 @@ _?curses.color_pair -(os|posix).EFD_CLOEXEC -(os|posix).EFD_NONBLOCK -(os|posix).EFD_SEMAPHORE (os|posix).SPLICE_F_MORE (os|posix).SPLICE_F_MOVE (os|posix).SPLICE_F_NONBLOCK (os|posix).setresgid (os|posix).setresuid (os|posix).sendfile -(os|posix).eventfd -(os|posix).eventfd_read -(os|posix).eventfd_write (os|posix).splice signal.sigtimedwait signal.sigwaitinfo diff --git a/tests/stubtest_allowlists/linux-py311.txt b/tests/stubtest_allowlists/linux-py311.txt index ebf77b08f..c8ac37c37 100644 --- a/tests/stubtest_allowlists/linux-py311.txt +++ b/tests/stubtest_allowlists/linux-py311.txt @@ -1,17 +1,11 @@ _?curses.color_pair mmap.MAP_STACK -(os|posix).EFD_CLOEXEC -(os|posix).EFD_NONBLOCK -(os|posix).EFD_SEMAPHORE (os|posix).SPLICE_F_MORE (os|posix).SPLICE_F_MOVE (os|posix).SPLICE_F_NONBLOCK (os|posix).setresgid (os|posix).setresuid (os|posix).sendfile -(os|posix).eventfd -(os|posix).eventfd_read -(os|posix).eventfd_write (os|posix).splice signal.sigtimedwait signal.sigwaitinfo diff --git a/tests/stubtest_allowlists/linux-py312.txt b/tests/stubtest_allowlists/linux-py312.txt index f22872fb6..5bbb57d4f 100644 --- a/tests/stubtest_allowlists/linux-py312.txt +++ b/tests/stubtest_allowlists/linux-py312.txt @@ -1,11 +1,5 @@ _?curses.color_pair _posixsubprocess.fork_exec -(os|posix).EFD_CLOEXEC -(os|posix).EFD_NONBLOCK -(os|posix).EFD_SEMAPHORE -(os|posix).eventfd -(os|posix).eventfd_read -(os|posix).eventfd_write (os|posix).sendfile (os|posix).setns (os|posix).setresgid @@ -14,7 +8,6 @@ _posixsubprocess.fork_exec (os|posix).SPLICE_F_MORE (os|posix).SPLICE_F_MOVE (os|posix).SPLICE_F_NONBLOCK -(os|posix).unshare fcntl.FICLONE fcntl.FICLONERANGE mmap.MAP_STACK