From: Petr Spacek Date: Wed, 25 Mar 2015 08:33:14 +0000 (+0100) Subject: Convert NoAnswer exception to the new DNSException style. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0ef4c7d10e0273219c8839f01ad9dc4d40d6c25b;p=thirdparty%2Fdnspython.git Convert NoAnswer exception to the new DNSException style. str() for paramerized exceptions returns string like: The DNS response does not contain an answer to the question: localhost. IN URI --- diff --git a/dns/resolver.py b/dns/resolver.py index 7e33d1b4..bd4b0ec3 100644 --- a/dns/resolver.py +++ b/dns/resolver.py @@ -73,19 +73,11 @@ class YXDOMAIN(dns.exception.DNSException): Timeout = dns.exception.Timeout + class NoAnswer(dns.exception.DNSException): """The DNS response does not contain an answer to the question.""" - def __init__(self, question=None): - super(dns.exception.DNSException, self).__init__() - self.question = question - - def __str__(self): - message = self.__doc__ - if self.question: - message = message[0:-1] - for q in self.question: - message += ' %s' % q - return message + fmt = '%s: {question}' % __doc__[:-1] + supp_kwargs = set(['question']) class NoNameservers(dns.exception.DNSException): @@ -181,7 +173,7 @@ class Answer(object): if raise_on_no_answer: raise NoAnswer(question=response.question) if rrset is None and raise_on_no_answer: - raise NoAnswer(question=response.question) + raise NoAnswer(question=request.question) self.canonical_name = qname self.rrset = rrset if rrset is None: