import _winreg # pylint: disable=import-error
class NXDOMAIN(dns.exception.DNSException):
-
"""The DNS query name does not exist."""
supp_kwargs = set(['qnames', 'responses'])
fmt = None # we have our own __str__ implementation
class YXDOMAIN(dns.exception.DNSException):
-
"""The DNS query name is too long after DNAME substitution."""
# The definition of the Timeout exception has moved from here to the
class NoAnswer(dns.exception.DNSException):
-
"""The DNS response does not contain an answer to the question."""
fmt = 'The DNS response does not contain an answer ' + \
'to the question: {query}'
class NoNameservers(dns.exception.DNSException):
-
"""All nameservers failed to answer the query.
errors: list of servers and respective errors
class NotAbsolute(dns.exception.DNSException):
-
"""An absolute domain name is required but a relative name was provided."""
class NoRootSOA(dns.exception.DNSException):
-
"""There is no SOA RR at the DNS root name. This should never happen!"""
class NoMetaqueries(dns.exception.DNSException):
-
"""DNS metaqueries are not allowed."""
class Answer(object):
-
"""DNS stub resolver answer
Instances of this class bundle up the result of a successful DNS
class Cache(object):
-
"""Simple DNS answer cache.
@ivar data: A dictionary of cached data
class LRUCacheNode(object):
-
- """LRUCache node.
- """
+ """LRUCache node."""
def __init__(self, key, value):
self.key = key
class LRUCache(object):
-
"""Bounded least-recently-used DNS answer cache.
This cache is better than the simple cache (above) if you're
class Resolver(object):
-
"""DNS stub resolver
@ivar domain: The domain of this host
The resolver to use may be specified; if it's not, the default
resolver will be used.
- @param resolver: the resolver to use
- @type resolver: dns.resolver.Resolver object or None
+ resolver, a ``dns.resolver.Resolver`` or ``None``, the resolver to use.
"""
+
if resolver is None:
resolver = get_default_resolver()
global _resolver
def restore_system_resolver():
- """Undo the effects of override_system_resolver().
- """
+ """Undo the effects of prior override_system_resolver()."""
+
global _resolver
_resolver = None
socket.getaddrinfo = _original_getaddrinfo
.. autoexception:: dns.rdataset.DifferingCovers
.. autoexception:: dns.rdataset.IncompatibleTypes
+dns.resolver Exceptions
+-----------------------
+
+.. autoexception:: dns.resolver.NoAnswer
+.. autoexception:: dns.resolver.NoMetaqueries
+.. autoexception:: dns.resolver.NoNameservers
+.. autoexception:: dns.resolver.NoRootSOA
+.. autoexception:: dns.resolver.NotAbsolute
+.. autoexception:: dns.resolver.NXDOMAIN
+.. autoexception:: dns.resolver.YXDOMAIN
+
dns.tokenizer Exceptions
------------------------
--- /dev/null
+.. _resolver-override:
+
+Overriding the System Resolver
+------------------------------
+
+Sometimes it can be useful to make all of Python use dnspython's resolver
+rather than the default functionality in the ``socket`` module. Dnspython
+can redefine the entires in the socket module to point at its own code, and
+it can also restore them back to the regular Python defaults.
+
+.. autofunction:: dns.resolver.override_system_resolver
+.. autofunction:: dns.resolver.restore_system_resolver