diff options
| author | Bob Halley <halley@dnspython.org> | 2020-09-03 07:46:53 -0700 |
|---|---|---|
| committer | Bob Halley <halley@dnspython.org> | 2020-09-03 07:46:53 -0700 |
| commit | 78362aa6b9bce8f0942577c72773cb36c5050b92 (patch) | |
| tree | 180f8147ec43693d0e84852f762b4783e3741860 /dns | |
| parent | 1f1888d35b820f67f3bb9262427e8b64f44d62f8 (diff) | |
| download | dnspython-full_match.tar.gz | |
fix rrset match signature problemsfull_match
Diffstat (limited to 'dns')
| -rw-r--r-- | dns/message.py | 3 | ||||
| -rw-r--r-- | dns/rrset.py | 29 |
2 files changed, 24 insertions, 8 deletions
diff --git a/dns/message.py b/dns/message.py index ea71a45..9824e70 100644 --- a/dns/message.py +++ b/dns/message.py @@ -351,7 +351,8 @@ class Message: return rrset else: for rrset in section: - if rrset.match(name, rdclass, rdtype, covers, deleting): + if rrset.full_match(name, rdclass, rdtype, covers, + deleting): return rrset if not create: raise KeyError diff --git a/dns/rrset.py b/dns/rrset.py index adfcad9..a71d457 100644 --- a/dns/rrset.py +++ b/dns/rrset.py @@ -76,22 +76,37 @@ class RRset(dns.rdataset.Rdataset): return False return super().__eq__(other) - # pylint: disable=arguments-differ + def match(self, *args, **kwargs): + """Does this rrset match the specified attributes? + + Behaves as :py:func:`full_match()` if the first argument is a + ``dns.name.Name``, and as :py:func:`dns.rdataset.Rdataset.match()` + otherwise. - def match(self, name, rdclass, rdtype, covers, - deleting=None): - """Returns ``True`` if this rrset matches the specified class, type, - covers, and deletion state. + (This behavior fixes a design mistake where the signature of this + method became incompatible with that of its superclass. The fix + makes RRsets matchable as Rdatasets while preserving backwards + compatibility.) """ + if isinstance(args[0], dns.name.Name): + return self.full_match(*args, **kwargs) + else: + return super().match(*args, **kwargs) + def full_match(self, name, rdclass, rdtype, covers, + deleting=None): + """Returns ``True`` if this rrset matches the specified name, class, + type, covers, and deletion state. + """ if not super().match(rdclass, rdtype, covers): return False if self.name != name or self.deleting != deleting: return False return True - def to_text(self, origin=None, relativize=True, - **kw): + # pylint: disable=arguments-differ + + def to_text(self, origin=None, relativize=True, **kw): """Convert the RRset into DNS zone file format. See ``dns.name.Name.choose_relativity`` for more information |
