Commit 98fa19b0 authored by Iustin Pop's avatar Iustin Pop Committed by Guido Trotter

Fix handling of errors from socket.gethostbyname

Socket functions can raise more than just gaierror. Most of the times,
socket.gethostbyname_ex will return gaierror, but rarely it will also
raise herror. For completeness, we catch all socket exceptions with data
of type (code, description).
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent e167599b
......@@ -739,8 +739,9 @@ class HostInfo:
"""
try:
result = socket.gethostbyname_ex(hostname)
except socket.gaierror, err:
# hostname not found in DNS
except (socket.gaierror, socket.herror, socket.error), err:
# hostname not found in DNS, or other socket exception in the
# (code, description format)
raise errors.ResolverError(hostname, err.args[0], err.args[1])
return result
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment