]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Fix [Issue #416], EAI_SYSTEM not defined on Windows.
authorBob Halley <halley@dnspython.org>
Mon, 4 May 2020 15:20:22 +0000 (08:20 -0700)
committerBob Halley <halley@dnspython.org>
Mon, 4 May 2020 15:20:22 +0000 (08:20 -0700)
dns/resolver.py

index e6f145b74536ba130d43a49bc5614a56041a5ec7..456bb6c469c4cc72cb0c31bd141eb54baabe1512 100644 (file)
@@ -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?