From: Bob Halley Date: Sat, 5 Jan 2019 18:58:15 +0000 (-0800) Subject: For _getaddrinfo(), if AI_ADDRCONFIG or AI_V4MAPPED are specified, raise X-Git-Tag: v2.0.0rc1~381 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f11f9f6d20012282a6554e6386cae3f151da0b53;p=thirdparty%2Fdnspython.git For _getaddrinfo(), if AI_ADDRCONFIG or AI_V4MAPPED are specified, raise socket.gaierror(socket.EAI_SYSTEM) instead of NotImplementedError, as higher level software will cope better. [Issue #316] --- diff --git a/dns/resolver.py b/dns/resolver.py index cdf77574..63326ffe 100644 --- a/dns/resolver.py +++ b/dns/resolver.py @@ -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 = []