From 103d45e1a5da2cba894ccdbb720d756002208d1f Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Sun, 1 Oct 2023 23:13:50 +0100 Subject: [PATCH 1/2] Add a few missing things on Windows, py310+ --- stdlib/_winapi.pyi | 1 + stdlib/asyncio/windows_events.pyi | 4 ++++ stdlib/msvcrt.pyi | 2 ++ tests/stubtest_allowlists/win32-py310.txt | 3 --- tests/stubtest_allowlists/win32-py311.txt | 5 ----- tests/stubtest_allowlists/win32-py312.txt | 12 ++++++------ 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/stdlib/_winapi.pyi b/stdlib/_winapi.pyi index b51d844701ac..e887fb38a7fa 100644 --- a/stdlib/_winapi.pyi +++ b/stdlib/_winapi.pyi @@ -255,3 +255,4 @@ if sys.platform == "win32": if sys.version_info >= (3, 12): def CopyFile2(existing_file_name: str, new_file_name: str, flags: int, progress_routine: int | None = None) -> int: ... + def NeedCurrentDirectoryForExePath(__exe_name: str) -> bool: ... diff --git a/stdlib/asyncio/windows_events.pyi b/stdlib/asyncio/windows_events.pyi index 2942a25c0ac4..730af3e3c8fa 100644 --- a/stdlib/asyncio/windows_events.pyi +++ b/stdlib/asyncio/windows_events.pyi @@ -60,6 +60,10 @@ if sys.platform == "win32": async def connect_pipe(self, address: str) -> windows_utils.PipeHandle: ... def wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: int | None = None) -> bool: ... def close(self) -> None: ... + if sys.version_info >= (3, 10): + def recvfrom_into( + self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0 + ) -> tuple[int, socket._RetAddress]: ... SelectorEventLoop = _WindowsSelectorEventLoop class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): diff --git a/stdlib/msvcrt.pyi b/stdlib/msvcrt.pyi index 5849b9b00ca0..aa44a53c7cc6 100644 --- a/stdlib/msvcrt.pyi +++ b/stdlib/msvcrt.pyi @@ -26,3 +26,5 @@ if sys.platform == "win32": def ungetch(__char: bytes | bytearray) -> None: ... def ungetwch(__unicode_char: str) -> None: ... def heapmin() -> None: ... + if sys.version_info >= (3, 10): + def GetErrorMode() -> int: ... # undocumented diff --git a/tests/stubtest_allowlists/win32-py310.txt b/tests/stubtest_allowlists/win32-py310.txt index 8a751827e088..f41da5612269 100644 --- a/tests/stubtest_allowlists/win32-py310.txt +++ b/tests/stubtest_allowlists/win32-py310.txt @@ -1,6 +1,3 @@ -# Exists at runtime, but missing from stubs -msvcrt.GetErrorMode - # pathlib methods that exist on Windows, but always raise NotImplementedError, # so are omitted from the stub pathlib.Path.is_mount diff --git a/tests/stubtest_allowlists/win32-py311.txt b/tests/stubtest_allowlists/win32-py311.txt index 3e0b0f0237fa..f41da5612269 100644 --- a/tests/stubtest_allowlists/win32-py311.txt +++ b/tests/stubtest_allowlists/win32-py311.txt @@ -1,8 +1,3 @@ -# Exists at runtime, missing from the stubs -asyncio.IocpProactor.recvfrom_into -asyncio.windows_events.IocpProactor.recvfrom_into -msvcrt.GetErrorMode - # pathlib methods that exist on Windows, but always raise NotImplementedError, # so are omitted from the stub pathlib.Path.is_mount diff --git a/tests/stubtest_allowlists/win32-py312.txt b/tests/stubtest_allowlists/win32-py312.txt index e3377eb16bfa..9e8b978810cf 100644 --- a/tests/stubtest_allowlists/win32-py312.txt +++ b/tests/stubtest_allowlists/win32-py312.txt @@ -1,8 +1,8 @@ -_winapi.NeedCurrentDirectoryForExePath -asyncio.IocpProactor.finish_socket_func -asyncio.IocpProactor.recvfrom_into -asyncio.windows_events.IocpProactor.finish_socket_func -asyncio.windows_events.IocpProactor.recvfrom_into -msvcrt.GetErrorMode +# CPython bug; waiting on https://github.com/python/cpython/pull/109790 to be backported ntpath.isdir os.path.isdir + +# Undocumented internal method, not really for public consumption. +# (Hard to add types for unless we add stubs for the undocumented _overlapped module...) +asyncio.IocpProactor.finish_socket_func +asyncio.windows_events.IocpProactor.finish_socket_func From 49e12172e51c56fa46db277336a0d026e2be5645 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 1 Oct 2023 23:19:42 +0100 Subject: [PATCH 2/2] +1 --- stdlib/asyncio/windows_events.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/asyncio/windows_events.pyi b/stdlib/asyncio/windows_events.pyi index 730af3e3c8fa..5dc88ddf5f28 100644 --- a/stdlib/asyncio/windows_events.pyi +++ b/stdlib/asyncio/windows_events.pyi @@ -60,7 +60,7 @@ if sys.platform == "win32": async def connect_pipe(self, address: str) -> windows_utils.PipeHandle: ... def wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: int | None = None) -> bool: ... def close(self) -> None: ... - if sys.version_info >= (3, 10): + if sys.version_info >= (3, 11): def recvfrom_into( self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0 ) -> tuple[int, socket._RetAddress]: ...