From c5bcc140ff9496cbe6733fdc65dd034e074b1b13 Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Sat, 19 Feb 2022 15:20:32 +0100 Subject: [PATCH] raise NoSOA if there is no SOA record --- dns/zone.py | 4 ++-- tests/test_zone.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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() -- 2.47.3