Skip to content

Commit e695458

Browse files
Add os.eventfd, os.eventfd_read and os.eventfd_write to Linux for Python 3.10+ (#10768)
Co-authored-by: Alex Waygood <[email protected]>
1 parent cec86eb commit e695458

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

stdlib/os/__init__.pyi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import sys
22
from _typeshed import (
33
AnyStr_co,
44
BytesPath,
5+
FileDescriptor,
56
FileDescriptorLike,
67
FileDescriptorOrPath,
78
GenericPath,
@@ -1057,6 +1058,14 @@ if sys.version_info >= (3, 12) and sys.platform == "win32":
10571058
def listmounts(volume: str) -> list[str]: ...
10581059
def listvolumes() -> list[str]: ...
10591060

1061+
if sys.version_info >= (3, 10) and sys.platform == "linux":
1062+
EFD_CLOEXEC: int
1063+
EFD_NONBLOCK: int
1064+
EFD_SEMAPHORE: int
1065+
def eventfd(initval: int, flags: int = 524288) -> FileDescriptor: ...
1066+
def eventfd_read(fd: FileDescriptor) -> int: ...
1067+
def eventfd_write(fd: FileDescriptor, value: int) -> None: ...
1068+
10601069
if sys.version_info >= (3, 12) and sys.platform == "linux":
10611070
CLONE_FILES: int
10621071
CLONE_FS: int
@@ -1072,3 +1081,4 @@ if sys.version_info >= (3, 12) and sys.platform == "linux":
10721081
CLONE_SYSVSEM: int
10731082
CLONE_THREAD: int
10741083
CLONE_VM: int
1084+
def unshare(flags: int) -> None: ...

stdlib/posix.pyi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,16 @@ if sys.platform != "win32":
236236
removexattr as removexattr,
237237
setxattr as setxattr,
238238
)
239+
240+
if sys.version_info >= (3, 10):
241+
from os import (
242+
EFD_CLOEXEC as EFD_CLOEXEC,
243+
EFD_NONBLOCK as EFD_NONBLOCK,
244+
EFD_SEMAPHORE as EFD_SEMAPHORE,
245+
eventfd as eventfd,
246+
eventfd_read as eventfd_read,
247+
eventfd_write as eventfd_write,
248+
)
239249
else:
240250
from os import chflags as chflags, lchflags as lchflags, lchmod as lchmod
241251

@@ -330,6 +340,7 @@ if sys.platform != "win32":
330340
CLONE_SYSVSEM as CLONE_SYSVSEM,
331341
CLONE_THREAD as CLONE_THREAD,
332342
CLONE_VM as CLONE_VM,
343+
unshare as unshare,
333344
)
334345

335346
# Not same as os.environ or os.environb

tests/stubtest_allowlists/linux-py310.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
_?curses.color_pair
2-
(os|posix).EFD_CLOEXEC
3-
(os|posix).EFD_NONBLOCK
4-
(os|posix).EFD_SEMAPHORE
52
(os|posix).SPLICE_F_MORE
63
(os|posix).SPLICE_F_MOVE
74
(os|posix).SPLICE_F_NONBLOCK
85
(os|posix).setresgid
96
(os|posix).setresuid
107
(os|posix).sendfile
11-
(os|posix).eventfd
12-
(os|posix).eventfd_read
13-
(os|posix).eventfd_write
148
(os|posix).splice
159
signal.sigtimedwait
1610
signal.sigwaitinfo

tests/stubtest_allowlists/linux-py311.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
_?curses.color_pair
22
mmap.MAP_STACK
3-
(os|posix).EFD_CLOEXEC
4-
(os|posix).EFD_NONBLOCK
5-
(os|posix).EFD_SEMAPHORE
63
(os|posix).SPLICE_F_MORE
74
(os|posix).SPLICE_F_MOVE
85
(os|posix).SPLICE_F_NONBLOCK
96
(os|posix).setresgid
107
(os|posix).setresuid
118
(os|posix).sendfile
12-
(os|posix).eventfd
13-
(os|posix).eventfd_read
14-
(os|posix).eventfd_write
159
(os|posix).splice
1610
signal.sigtimedwait
1711
signal.sigwaitinfo

tests/stubtest_allowlists/linux-py312.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
_?curses.color_pair
22
_posixsubprocess.fork_exec
3-
(os|posix).EFD_CLOEXEC
4-
(os|posix).EFD_NONBLOCK
5-
(os|posix).EFD_SEMAPHORE
6-
(os|posix).eventfd
7-
(os|posix).eventfd_read
8-
(os|posix).eventfd_write
93
(os|posix).sendfile
104
(os|posix).setns
115
(os|posix).setresgid
@@ -14,7 +8,6 @@ _posixsubprocess.fork_exec
148
(os|posix).SPLICE_F_MORE
159
(os|posix).SPLICE_F_MOVE
1610
(os|posix).SPLICE_F_NONBLOCK
17-
(os|posix).unshare
1811
fcntl.FICLONE
1912
fcntl.FICLONERANGE
2013
mmap.MAP_STACK

0 commit comments

Comments
 (0)