]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Add response to NoAnswer exception.
authorPetr Spacek <pspacek@redhat.com>
Fri, 27 Mar 2015 14:51:24 +0000 (15:51 +0100)
committerPetr Viktorin <pviktori@redhat.com>
Thu, 21 May 2015 12:25:41 +0000 (14:25 +0200)
Only question section is returned from str(NoAnswer).
Whole response variable is intended for application debug logs
and is not returned from str().

dns/resolver.py

index bd4b0ec3a26a94be1560e6f70cba6b819c6b866d..cd3d1c2007144c20758e91f20bc7111c52b2a915 100644 (file)
@@ -76,9 +76,12 @@ Timeout = dns.exception.Timeout
 
 class NoAnswer(dns.exception.DNSException):
     """The DNS response does not contain an answer to the question."""
-    fmt = '%s: {question}' % __doc__[:-1]
-    supp_kwargs = set(['question'])
+    fmt = '%s: {query}' % __doc__[:-1]
+    supp_kwargs = set(['response'])
 
+    def _fmt_kwargs(self, **kwargs):
+        return super(NoAnswer, self)._fmt_kwargs(
+            query=kwargs['response'].question)
 
 class NoNameservers(dns.exception.DNSException):
     """No non-broken nameservers are available to answer the query."""
@@ -171,9 +174,9 @@ class Answer(object):
                         if raise_on_no_answer:
                             raise NoAnswer(question=response.question)
                 if raise_on_no_answer:
-                    raise NoAnswer(question=response.question)
+                    raise NoAnswer(response=response)
         if rrset is None and raise_on_no_answer:
-            raise NoAnswer(question=request.question)
+            raise NoAnswer(response=response)
         self.canonical_name = qname
         self.rrset = rrset
         if rrset is None: