From: Petr Spacek Date: Wed, 25 Mar 2015 08:33:14 +0000 (+0100) Subject: Convert NoAnswer exception to the new DNSException style. X-Git-Tag: v1.13.0~27^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=107b909d8df97e4e5474055bc557cf0690e60908;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 fbaaaca3..aaf60813 100644 --- a/dns/resolver.py +++ b/dns/resolver.py @@ -70,19 +70,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): @@ -178,7 +170,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: