From: Bob Halley Date: Wed, 11 May 2016 21:54:30 +0000 (-0700) Subject: Allow an origin of None to be specified when constructing a X-Git-Tag: v1.14.0~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ecd53c269ed8c7df78e34ba3935294526e41378;p=thirdparty%2Fdnspython.git Allow an origin of None to be specified when constructing a Zone object. [issue #153] --- diff --git a/dns/zone.py b/dns/zone.py index 6d2b5df8..81e0fcff 100644 --- a/dns/zone.py +++ b/dns/zone.py @@ -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 = {} diff --git a/tests/test_zone.py b/tests/test_zone.py index 9e3fd2cd..9338f53c 100644 --- a/tests/test_zone.py +++ b/tests/test_zone.py @@ -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()