diff options
Diffstat (limited to 'lib/dnspython/dns/resolver.py')
-rw-r--r-- | lib/dnspython/dns/resolver.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/dnspython/dns/resolver.py b/lib/dnspython/dns/resolver.py index cd0e5f804b..f803eb6d20 100644 --- a/lib/dnspython/dns/resolver.py +++ b/lib/dnspython/dns/resolver.py @@ -569,9 +569,9 @@ class Resolver(object): if isinstance(qname, (str, unicode)): qname = dns.name.from_text(qname, None) - if isinstance(rdtype, str): + if isinstance(rdtype, (str, unicode)): rdtype = dns.rdatatype.from_text(rdtype) - if isinstance(rdclass, str): + if isinstance(rdclass, (str, unicode)): rdclass = dns.rdataclass.from_text(rdclass) qnames_to_try = [] if qname.is_absolute(): @@ -754,9 +754,12 @@ def zone_for_name(name, rdclass=dns.rdataclass.IN, tcp=False, resolver=None): while 1: try: answer = resolver.query(name, dns.rdatatype.SOA, rdclass, tcp) - return name + if answer.rrset.name == name: + return name + # otherwise we were CNAMEd or DNAMEd and need to look higher except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer): - try: - name = name.parent() - except dns.name.NoParent: - raise NoRootSOA + pass + try: + name = name.parent() + except dns.name.NoParent: + raise NoRootSOA |