]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
raise NoSOA if there is no SOA record
authorJakob Schlyter <jakob@kirei.se>
Sat, 19 Feb 2022 14:20:32 +0000 (15:20 +0100)
committerJakob Schlyter <jakob@kirei.se>
Sat, 19 Feb 2022 14:20:32 +0000 (15:20 +0100)
dns/zone.py
tests/test_zone.py

index c126f5c20e14e85242db6ef95115607a9b82df03..e9a82d2e1b2a9af9329bf03de159c7393f14022f 100644 (file)
@@ -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):
index 8bdb49fc5fb36e39b2ed2c53cbee9ecfbe984a86..6ef669b6c5c826d4146f266dd12ff9119099ab73 100644 (file)
@@ -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()