From: Bob Halley Date: Mon, 4 May 2020 15:20:22 +0000 (-0700) Subject: Fix [Issue #416], EAI_SYSTEM not defined on Windows. X-Git-Tag: v2.0.0rc1~263 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d91f16374b9ace86b6916a129ca405f3b05db561;p=thirdparty%2Fdnspython.git Fix [Issue #416], EAI_SYSTEM not defined on Windows. --- diff --git a/dns/resolver.py b/dns/resolver.py index e6f145b7..456bb6c4 100644 --- a/dns/resolver.py +++ b/dns/resolver.py @@ -1234,7 +1234,12 @@ def _getaddrinfo(host=None, service=None, family=socket.AF_UNSPEC, socktype=0, # Not implemented. We raise a gaierror as opposed to a # NotImplementedError as it helps callers handle errors more # appropriately. [Issue #316] - raise socket.gaierror(socket.EAI_SYSTEM) + # + # We raise EAI_FAIL as opposed to EAI_SYSTEM because there is + # no EAI_SYSTEM on Windows [Issue #416]. We didn't go for + # EAI_BADFLAGS as the flags aren't bad, we just don't + # implement them. + raise socket.gaierror(socket.EAI_FAIL) if host is None and service is None: raise socket.gaierror(socket.EAI_NONAME) v6addrs = [] @@ -1274,7 +1279,10 @@ def _getaddrinfo(host=None, service=None, family=socket.AF_UNSPEC, socktype=0, except dns.resolver.NXDOMAIN: raise socket.gaierror(socket.EAI_NONAME) except Exception: - raise socket.gaierror(socket.EAI_SYSTEM) + # We raise EAI_AGAIN here as the failure may be temporary + # (e.g. a timeout) and EAI_SYSTEM isn't defined on Windows. + # [Issue #416] + raise socket.gaierror(socket.EAI_AGAIN) port = None try: # Is it a port literal?