From 9e79a100b3a9f1ae931b46cea56dc3ef99122ae5 Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Mon, 25 Sep 2023 17:20:37 +0200 Subject: [PATCH] Add `os.splice` and flags on Linux for Python 3.10+ (#10771) --- stdlib/os/__init__.pyi | 11 +++++++++++ stdlib/posix.pyi | 4 ++++ tests/stubtest_allowlists/linux-py310.txt | 4 ---- tests/stubtest_allowlists/linux-py311.txt | 4 ---- tests/stubtest_allowlists/linux-py312.txt | 4 ---- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index d0761fe89..d9b7eed6d 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -1062,9 +1062,20 @@ if sys.version_info >= (3, 10) and sys.platform == "linux": EFD_CLOEXEC: int EFD_NONBLOCK: int EFD_SEMAPHORE: int + SPLICE_F_MORE: int + SPLICE_F_MOVE: int + SPLICE_F_NONBLOCK: int def eventfd(initval: int, flags: int = 524288) -> FileDescriptor: ... def eventfd_read(fd: FileDescriptor) -> int: ... def eventfd_write(fd: FileDescriptor, value: int) -> None: ... + def splice( + src: FileDescriptor, + dst: FileDescriptor, + count: int, + offset_src: int | None = ..., + offset_dst: int | None = ..., + flags: int = 0, + ) -> int: ... if sys.version_info >= (3, 12) and sys.platform == "linux": CLONE_FILES: int diff --git a/stdlib/posix.pyi b/stdlib/posix.pyi index 6c66c0d6a..6a6cd6bba 100644 --- a/stdlib/posix.pyi +++ b/stdlib/posix.pyi @@ -242,9 +242,13 @@ if sys.platform != "win32": EFD_CLOEXEC as EFD_CLOEXEC, EFD_NONBLOCK as EFD_NONBLOCK, EFD_SEMAPHORE as EFD_SEMAPHORE, + SPLICE_F_MORE as SPLICE_F_MORE, + SPLICE_F_MOVE as SPLICE_F_MOVE, + SPLICE_F_NONBLOCK as SPLICE_F_NONBLOCK, eventfd as eventfd, eventfd_read as eventfd_read, eventfd_write as eventfd_write, + splice as splice, ) else: from os import chflags as chflags, lchflags as lchflags, lchmod as lchmod diff --git a/tests/stubtest_allowlists/linux-py310.txt b/tests/stubtest_allowlists/linux-py310.txt index 7c8f906da..8b3d6e1c4 100644 --- a/tests/stubtest_allowlists/linux-py310.txt +++ b/tests/stubtest_allowlists/linux-py310.txt @@ -1,11 +1,7 @@ _?curses.color_pair -(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).splice signal.sigtimedwait signal.sigwaitinfo diff --git a/tests/stubtest_allowlists/linux-py311.txt b/tests/stubtest_allowlists/linux-py311.txt index c8ac37c37..c13c4e322 100644 --- a/tests/stubtest_allowlists/linux-py311.txt +++ b/tests/stubtest_allowlists/linux-py311.txt @@ -1,12 +1,8 @@ _?curses.color_pair mmap.MAP_STACK -(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).splice signal.sigtimedwait signal.sigwaitinfo xxlimited.Xxo.x_exports diff --git a/tests/stubtest_allowlists/linux-py312.txt b/tests/stubtest_allowlists/linux-py312.txt index 5bbb57d4f..0ede3b23d 100644 --- a/tests/stubtest_allowlists/linux-py312.txt +++ b/tests/stubtest_allowlists/linux-py312.txt @@ -4,10 +4,6 @@ _posixsubprocess.fork_exec (os|posix).setns (os|posix).setresgid (os|posix).setresuid -(os|posix).splice -(os|posix).SPLICE_F_MORE -(os|posix).SPLICE_F_MOVE -(os|posix).SPLICE_F_NONBLOCK fcntl.FICLONE fcntl.FICLONERANGE mmap.MAP_STACK