From b23159ed643d82171b3e8a8dce94a002a3f20bb5 Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Mon, 13 Jul 2026 15:01:23 +0530 Subject: [PATCH] gh-89696: Fix loop.sock_connect docs on address resolution The docs claimed unconditionally that the address no longer needs to be resolved, but only SelectorEventLoop does that. ProactorEventLoop, the default event loop on Windows, passes the address straight to ConnectEx() and WSAConnect(), which parse it with WSAStringToAddress() and therefore only accept numeric addresses. --- Doc/library/asyncio-eventloop.rst | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index 65bc349e2a727d..e6cdd4e57475b2 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -1145,12 +1145,21 @@ convenient. *sock* must be a non-blocking socket. + With :class:`SelectorEventLoop`, *address* does not need to be resolved: + for :const:`~socket.AF_INET` and :const:`~socket.AF_INET6` sockets, + ``sock_connect`` first checks whether *address* is already resolved by + calling :func:`socket.inet_pton`, and uses :meth:`loop.getaddrinfo` to + resolve it if it is not. + + :class:`ProactorEventLoop`, the default event loop on Windows, does not + resolve *address*. The host must already be a numeric IP address; passing + a host name raises :exc:`OSError`. Resolve the address with + :meth:`loop.getaddrinfo` first, or use :meth:`loop.create_connection`, + which resolves the address on every platform. + .. versionchanged:: 3.5.2 - ``address`` no longer needs to be resolved. ``sock_connect`` - will try to check if the *address* is already resolved by calling - :func:`socket.inet_pton`. If not, - :meth:`loop.getaddrinfo` will be used to resolve the - *address*. + With :class:`SelectorEventLoop`, ``address`` no longer needs to be + resolved. .. seealso::