]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Allow an origin of None to be specified when constructing a
authorBob Halley <halley@dnspython.org>
Wed, 11 May 2016 21:54:30 +0000 (14:54 -0700)
committerBob Halley <halley@dnspython.org>
Wed, 11 May 2016 21:54:30 +0000 (14:54 -0700)
Zone object.
[issue #153]

dns/zone.py
tests/test_zone.py

index 6d2b5df870ade959cc0614d5c083691e840d6184..81e0fcffadb2de769d5d107214b0dd1796c98079 100644 (file)
@@ -90,13 +90,14 @@ class Zone(object):
         @param rdclass: The zone's rdata class; the default is class IN.
         @type rdclass: int"""
 
-        if isinstance(origin, string_types):
-            origin = dns.name.from_text(origin)
-        elif not isinstance(origin, dns.name.Name):
-            raise ValueError("origin parameter must be convertable to a "
-                             "DNS name")
-        if not origin.is_absolute():
-            raise ValueError("origin parameter must be an absolute name")
+        if origin is not None:
+            if isinstance(origin, string_types):
+                origin = dns.name.from_text(origin)
+            elif not isinstance(origin, dns.name.Name):
+                raise ValueError("origin parameter must be convertable to a "
+                                 "DNS name")
+            if not origin.is_absolute():
+                raise ValueError("origin parameter must be an absolute name")
         self.origin = origin
         self.rdclass = rdclass
         self.nodes = {}
index 9e3fd2cdb9b3a0a01bf58c94beb6fce7848c5b01..9338f53c9ee697961940a6b9a9730f4a00b2b104 100644 (file)
@@ -433,5 +433,8 @@ class ZoneTestCase(unittest.TestCase):
             z = dns.zone.Zone(1.0)
         self.failUnlessRaises(ValueError, bad2)
 
+    def testZoneOriginNone(self):
+        z = dns.zone.Zone(None)
+
 if __name__ == '__main__':
     unittest.main()