From: Jakob Schlyter Date: Sat, 19 Feb 2022 14:20:32 +0000 (+0100) Subject: raise NoSOA if there is no SOA record X-Git-Tag: v2.3.0rc1~121^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5bcc140ff9496cbe6733fdc65dd034e074b1b13;p=thirdparty%2Fdnspython.git raise NoSOA if there is no SOA record --- diff --git a/dns/zone.py b/dns/zone.py index c126f5c2..e9a82d2e 100644 --- a/dns/zone.py +++ b/dns/zone.py @@ -716,7 +716,7 @@ class Zone(dns.transaction.TransactionManager): def get_soa(self): """Get the zone SOA RR. - Raises ``KeyError`` if there is no SOA record. + Raises ``dns.zone.NoSOA`` if there is no SOA RRset. Returns a ``dns.node.Node``. """ @@ -726,7 +726,7 @@ class Zone(dns.transaction.TransactionManager): origin_name = self.origin soa = self.get_rdataset(origin_name, dns.rdatatype.SOA) if soa is None: - raise KeyError + raise NoSOA return soa[0] def _compute_digest(self, hash_algorithm, scheme=DigestScheme.SIMPLE): diff --git a/tests/test_zone.py b/tests/test_zone.py index 8bdb49fc..6ef669b6 100644 --- a/tests/test_zone.py +++ b/tests/test_zone.py @@ -1071,7 +1071,7 @@ class VersionedZoneTestCase(unittest.TestCase): def testGetSoaEmptyZone(self): z = dns.zone.Zone('example.') - with self.assertRaises(KeyError): + with self.assertRaises(dns.zone.NoSOA): soa = z.get_soa()