]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
add as_rdataclass() and as_rdatatype(), and use them in rdata constructor
authorBob Halley <halley@dnspython.org>
Fri, 21 Aug 2020 17:12:17 +0000 (10:12 -0700)
committerBob Halley <halley@dnspython.org>
Fri, 21 Aug 2020 17:12:17 +0000 (10:12 -0700)
dns/rdata.py

index a5d3a66a51a2db1d467f1449da502449a63614c9..2dec6e6eba1200b54ec268faa4c46ed04275c73e 100644 (file)
@@ -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):