bpo-27929: resolve names only for AF_INET/AF_INET6 with asyncio (GH-32131)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
(cherry picked from commit 5c30388f3c)

Co-authored-by: Vincent Bernat <vincent@bernat.ch>
This commit is contained in:
Miss Islington (bot) 2022-03-28 15:15:05 -07:00 committed by GitHub
parent 5944807b09
commit 2bcbc3113d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -487,7 +487,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
if self._debug and sock.gettimeout() != 0: if self._debug and sock.gettimeout() != 0:
raise ValueError("the socket must be non-blocking") raise ValueError("the socket must be non-blocking")
if not hasattr(socket, 'AF_UNIX') or sock.family != socket.AF_UNIX: if sock.family == socket.AF_INET or (
base_events._HAS_IPv6 and sock.family == socket.AF_INET6):
resolved = await self._ensure_resolved( resolved = await self._ensure_resolved(
address, family=sock.family, type=sock.type, proto=sock.proto, address, family=sock.family, type=sock.type, proto=sock.proto,
loop=self, loop=self,

View file

@ -0,0 +1,3 @@
Fix :meth:`asyncio.loop.sock_connect` to only resolve names for :const:`socket.AF_INET` or
:const:`socket.AF_INET6` families. Resolution may not make sense for other families,
like :const:`socket.AF_BLUETOOTH` and :const:`socket.AF_UNIX`.