summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2020-08-21 10:12:17 -0700
committerBob Halley <halley@dnspython.org>2020-08-21 10:12:17 -0700
commit52b2a74005faf54e1e80e0e196341cc71c501c3b (patch)
tree23d769cdcff1fb77c55cb2f6b1ed3c4c8f3cddbd
parentc27f5a6e5265576d404d53afc1d175abaaf218a7 (diff)
downloaddnspython-52b2a74005faf54e1e80e0e196341cc71c501c3b.tar.gz
add as_rdataclass() and as_rdatatype(), and use them in rdata constructor
-rw-r--r--dns/rdata.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/dns/rdata.py b/dns/rdata.py
index a5d3a66..2dec6e6 100644
--- a/dns/rdata.py
+++ b/dns/rdata.py
@@ -111,8 +111,8 @@ class Rdata:
*rdtype*, an ``int`` is the rdatatype of the Rdata.
"""
- self.rdclass = rdclass
- self.rdtype = rdtype
+ self.rdclass = self.as_rdataclass(rdclass)
+ self.rdtype = self.as_rdatatype(rdtype)
self.rdcomment = None
def _get_all_slots(self):
@@ -337,6 +337,12 @@ class Rdata:
# doesn't do any additional checking.
return value
+ def as_rdataclass(self, value):
+ return dns.rdataclass.RdataClass.make(value)
+
+ def as_rdatatype(self, value):
+ return dns.rdatatype.RdataType.make(value)
+
class GenericRdata(Rdata):