From 96eaa767ddfb5b206e0a57a5663daf07212b2675 Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Fri, 22 Sep 2023 17:12:50 +0200 Subject: [PATCH] Update os on Windows, Python3.12+ (#10749) Co-authored-by: Alex Waygood --- stdlib/os/__init__.pyi | 20 ++++++++++++++++---- tests/stubtest_allowlists/win32-py312.txt | 7 ------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index f3424b480261..a83bde62a57b 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -341,6 +341,11 @@ class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, flo if sys.version_info >= (3, 8): @property def st_reparse_tag(self) -> int: ... + if sys.version_info >= (3, 12): + @property + def st_birthtime(self) -> float: ... # time of file creation in seconds + @property + def st_birthtime_ns(self) -> int: ... # time of file creation in nanoseconds else: @property def st_blocks(self) -> int: ... # number of blocks allocated for file @@ -349,13 +354,13 @@ class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, flo @property def st_rdev(self) -> int: ... # type of device if an inode device if sys.platform != "linux": - # These properties are available on MacOS, but not on Windows or Ubuntu. + # These properties are available on MacOS, but not Ubuntu. # On other Unix systems (such as FreeBSD), the following attributes may be # available (but may be only filled out if root tries to use them): @property def st_gen(self) -> int: ... # file generation number @property - def st_birthtime(self) -> int: ... # time of file creation + def st_birthtime(self) -> float: ... # time of file creation in seconds if sys.platform == "darwin": @property def st_flags(self) -> int: ... # user defined flags for file @@ -616,13 +621,15 @@ def open(path: StrOrBytesPath, flags: int, mode: int = 0o777, *, dir_fd: int | N def pipe() -> tuple[int, int]: ... def read(__fd: int, __length: int) -> bytes: ... +if sys.version_info >= (3, 12) or sys.platform != "win32": + def get_blocking(__fd: int) -> bool: ... + 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: ... - def get_blocking(__fd: int) -> bool: ... - def set_blocking(__fd: int, __blocking: bool) -> None: ... def lockf(__fd: int, __command: int, __length: int) -> None: ... def openpty() -> tuple[int, int]: ... # some flavors of Unix if sys.platform != "darwin": @@ -1044,3 +1051,8 @@ if sys.version_info >= (3, 9): if sys.platform == "linux": def pidfd_open(pid: int, flags: int = ...) -> int: ... + +if sys.version_info >= (3, 12) and sys.platform == "win32": + def listdrives() -> list[str]: ... + def listmounts(volume: str) -> list[str]: ... + def listvolumes() -> list[str]: ... diff --git a/tests/stubtest_allowlists/win32-py312.txt b/tests/stubtest_allowlists/win32-py312.txt index 7df0faeaa256..e3377eb16bfa 100644 --- a/tests/stubtest_allowlists/win32-py312.txt +++ b/tests/stubtest_allowlists/win32-py312.txt @@ -5,11 +5,4 @@ asyncio.windows_events.IocpProactor.finish_socket_func asyncio.windows_events.IocpProactor.recvfrom_into msvcrt.GetErrorMode ntpath.isdir -os.get_blocking -os.listdrives -os.listmounts -os.listvolumes os.path.isdir -os.set_blocking -os.stat_result.st_birthtime -os.stat_result.st_birthtime_ns