From 52b2a74005faf54e1e80e0e196341cc71c501c3b Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Fri, 21 Aug 2020 10:12:17 -0700 Subject: [PATCH] add as_rdataclass() and as_rdatatype(), and use them in rdata constructor --- dns/rdata.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dns/rdata.py b/dns/rdata.py index a5d3a66a..2dec6e6e 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): -- 2.47.3