From dbe4d32a2a7e9c92689cdf850c00153c59ac2286 Mon Sep 17 00:00:00 2001 From: Max Muoto Date: Sun, 15 Sep 2024 15:13:09 -0500 Subject: [PATCH] Add `fchmod` and `lchmod` for Windows on 3.13 (#12662) --- stdlib/@tests/stubtest_allowlists/win32-py313.txt | 4 ---- stdlib/nt.pyi | 2 ++ stdlib/os/__init__.pyi | 11 +++++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/win32-py313.txt b/stdlib/@tests/stubtest_allowlists/win32-py313.txt index 05a81a4eb..1f2749e76 100644 --- a/stdlib/@tests/stubtest_allowlists/win32-py313.txt +++ b/stdlib/@tests/stubtest_allowlists/win32-py313.txt @@ -1,11 +1,7 @@ # New in py313 (triage these!) -nt.fchmod -nt.lchmod ntpath.exists ntpath.lexists ntpath.splitroot -os.fchmod -os.lchmod os.path.exists os.path.lexists diff --git a/stdlib/nt.pyi b/stdlib/nt.pyi index 4066096f4..e1d57d09a 100644 --- a/stdlib/nt.pyi +++ b/stdlib/nt.pyi @@ -107,5 +107,7 @@ if sys.platform == "win32": listvolumes as listvolumes, set_blocking as set_blocking, ) + if sys.version_info >= (3, 13): + from os import fchmod as fchmod, lchmod as lchmod environ: dict[str, str] diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 700e0e9df..d7bb4883a 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -673,7 +673,6 @@ if sys.version_info >= (3, 12) or sys.platform != "win32": def set_blocking(fd: int, blocking: bool, /) -> None: ... if sys.platform != "win32": - def fchmod(fd: int, mode: int) -> None: ... def fchown(fd: int, uid: int, gid: int) -> None: ... def fpathconf(fd: int, name: str | int, /) -> int: ... def fstatvfs(fd: int, /) -> statvfs_result: ... @@ -754,7 +753,6 @@ def chmod(path: FileDescriptorOrPath, mode: int, *, dir_fd: int | None = None, f if sys.platform != "win32" and sys.platform != "linux": def chflags(path: StrOrBytesPath, flags: int, follow_symlinks: bool = True) -> None: ... # some flavors of Unix def lchflags(path: StrOrBytesPath, flags: int) -> None: ... - def lchmod(path: StrOrBytesPath, mode: int) -> None: ... if sys.platform != "win32": def chroot(path: StrOrBytesPath) -> None: ... @@ -1179,3 +1177,12 @@ if sys.version_info >= (3, 13) and sys.platform == "linux": def timerfd_settime_ns(fd: FileDescriptor, /, *, flags: int = 0, initial: int = 0, interval: int = 0) -> tuple[int, int]: ... def timerfd_gettime(fd: FileDescriptor, /) -> tuple[float, float]: ... def timerfd_gettime_ns(fd: FileDescriptor, /) -> tuple[int, int]: ... + +if sys.version_info >= (3, 13) or sys.platform != "win32": + # Added to Windows in 3.13. + def fchmod(fd: int, mode: int) -> None: ... + +if sys.platform != "linux": + if sys.version_info >= (3, 13) or sys.platform != "win32": + # Added to Windows in 3.13. + def lchmod(path: StrOrBytesPath, mode: int) -> None: ...