]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
For _getaddrinfo(), if AI_ADDRCONFIG or AI_V4MAPPED are specified, raise
authorBob Halley <halley@dnspython.org>
Sat, 5 Jan 2019 18:58:15 +0000 (10:58 -0800)
committerBob Halley <halley@dnspython.org>
Sat, 5 Jan 2019 18:58:15 +0000 (10:58 -0800)
socket.gaierror(socket.EAI_SYSTEM) instead of NotImplementedError, as higher
level software will cope better.  [Issue #316]

dns/resolver.py

index cdf775745684c98630edc92a28a8c1235cdcb6a5..63326ffed8969a36487e4a53ca9e8e93be28ece2 100644 (file)
@@ -1162,7 +1162,10 @@ _original_gethostbyaddr = socket.gethostbyaddr
 def _getaddrinfo(host=None, service=None, family=socket.AF_UNSPEC, socktype=0,
                  proto=0, flags=0):
     if flags & (socket.AI_ADDRCONFIG | socket.AI_V4MAPPED) != 0:
-        raise NotImplementedError
+        # 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)
     if host is None and service is None:
         raise socket.gaierror(socket.EAI_NONAME)
     v6addrs = []