]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Move creating a socket for a DoH query into the address's try..except
authorBob Halley <halley@dnspython.org>
Sat, 14 Dec 2024 19:26:17 +0000 (11:26 -0800)
committerBob Halley <halley@dnspython.org>
Sat, 14 Dec 2024 19:26:17 +0000 (11:26 -0800)
block so if creating fails, e.g. due to no IPv6, we try other addressess
if we've got any.  [#1169]

dns/query.py

index 9a9a4457c1667a905da6d469dc169b5e2bc6fb1d..6006a73794345922def15c173e4de14ff7fc4d52 100644 (file)
@@ -106,9 +106,9 @@ if _have_httpx:
                     )
                 else:
                     source = None
-                sock = _make_socket(af, socket.SOCK_STREAM, source)
-                attempt_expiration = _expiration_for_this_attempt(2.0, expiration)
                 try:
+                    sock = _make_socket(af, socket.SOCK_STREAM, source)
+                    attempt_expiration = _expiration_for_this_attempt(2.0, expiration)
                     _connect(
                         sock,
                         dns.inet.low_level_address_tuple((address, port), af),