From 860e34eec9873df0bd934df43b1efce32ea9964c Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 2 Oct 2023 16:04:11 +0100 Subject: [PATCH] Fix allowlist entries in `asyncio.windows_events` (#10824) And fix the return value of return value of `IocpProactor.recvfrom_into()`, which was incorrect Co-authored-by: Jelle Zijlstra --- stdlib/asyncio/windows_events.pyi | 10 ++++++++-- tests/stubtest_allowlists/win32.txt | 4 ---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/stdlib/asyncio/windows_events.pyi b/stdlib/asyncio/windows_events.pyi index 5dc88ddf5..8e643dd4a 100644 --- a/stdlib/asyncio/windows_events.pyi +++ b/stdlib/asyncio/windows_events.pyi @@ -1,6 +1,6 @@ import socket import sys -from _typeshed import Incomplete, WriteableBuffer +from _typeshed import Incomplete, ReadableBuffer, WriteableBuffer from collections.abc import Callable from typing import IO, Any, ClassVar, NoReturn from typing_extensions import Literal @@ -48,6 +48,12 @@ if sys.platform == "win32": def select(self, timeout: int | None = None) -> list[futures.Future[Any]]: ... def recv(self, conn: socket.socket, nbytes: int, flags: int = 0) -> futures.Future[bytes]: ... def recv_into(self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0) -> futures.Future[Any]: ... + def recvfrom( + self, conn: socket.socket, nbytes: int, flags: int = 0 + ) -> futures.Future[tuple[bytes, socket._RetAddress]]: ... + def sendto( + self, conn: socket.socket, buf: ReadableBuffer, flags: int = 0, addr: socket._Address | None = None + ) -> futures.Future[int]: ... def send(self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0) -> futures.Future[Any]: ... def accept(self, listener: socket.socket) -> futures.Future[Any]: ... def connect( @@ -63,7 +69,7 @@ if sys.platform == "win32": if sys.version_info >= (3, 11): def recvfrom_into( self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0 - ) -> tuple[int, socket._RetAddress]: ... + ) -> futures.Future[tuple[int, socket._RetAddress]]: ... SelectorEventLoop = _WindowsSelectorEventLoop class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): diff --git a/tests/stubtest_allowlists/win32.txt b/tests/stubtest_allowlists/win32.txt index 0e7e214e1..c44b591ec 100644 --- a/tests/stubtest_allowlists/win32.txt +++ b/tests/stubtest_allowlists/win32.txt @@ -10,10 +10,6 @@ _winapi.CreateFileMapping _winapi.MapViewOfFile _winapi.OpenFileMapping _winapi.VirtualQuerySize -asyncio.IocpProactor.recvfrom -asyncio.IocpProactor.sendto -asyncio.windows_events.IocpProactor.recvfrom -asyncio.windows_events.IocpProactor.sendto msvcrt.SetErrorMode ssl.SSLSocket.recvmsg ssl.SSLSocket.recvmsg_into