From 19a5f048ec2fdd60ca6e5cd8b68d5b70ad8e0556 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Sat, 14 Dec 2024 11:26:17 -0800 Subject: [PATCH] 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] --- dns/query.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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), -- 2.47.3