]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-27929: resolve names only for AF_INET/AF_INET6 with asyncio (GH-32131)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 28 Mar 2022 22:16:30 +0000 (15:16 -0700)
committerGitHub <noreply@github.com>
Mon, 28 Mar 2022 22:16:30 +0000 (15:16 -0700)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
(cherry picked from commit 5c30388f3c586ba2f33e349e22e5949cb92de621)

Co-authored-by: Vincent Bernat <vincent@bernat.ch>
Lib/asyncio/selector_events.py
Misc/NEWS.d/next/Library/2022-03-28-13-35-50.bpo-27929.j5mAmV.rst [new file with mode: 0644]

index 71080b8ad16c619f678c7f49292c116350f258d6..572d4a8ce12d498a70940013774fbf7b5408e782 100644 (file)
@@ -487,7 +487,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
         if self._debug and sock.gettimeout() != 0:
             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(
                 address, family=sock.family, type=sock.type, proto=sock.proto,
                 loop=self,
diff --git a/Misc/NEWS.d/next/Library/2022-03-28-13-35-50.bpo-27929.j5mAmV.rst b/Misc/NEWS.d/next/Library/2022-03-28-13-35-50.bpo-27929.j5mAmV.rst
new file mode 100644 (file)
index 0000000..4c80a10
--- /dev/null
@@ -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`.