From: Bob Halley Date: Sat, 14 Dec 2024 19:26:17 +0000 (-0800) Subject: Move creating a socket for a DoH query into the address's try..except X-Git-Tag: v2.8.0rc1~54 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=19a5f048ec2fdd60ca6e5cd8b68d5b70ad8e0556;p=thirdparty%2Fdnspython.git Move creating a socket for a DoH query into the address's try..except block so if creating fails, e.g. due to no IPv6, we try other addressess if we've got any. [#1169] --- diff --git a/dns/query.py b/dns/query.py index 9a9a4457..6006a737 100644 --- a/dns/query.py +++ b/dns/query.py @@ -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),