]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
add/adjust some no cover pragmas; fix missing catch of UnicodeError
authorBob Halley <halley@play-bow.org>
Tue, 30 Jun 2020 15:24:33 +0000 (08:24 -0700)
committerBob Halley <halley@play-bow.org>
Tue, 30 Jun 2020 15:24:33 +0000 (08:24 -0700)
dns/name.py

index 310b0322814bd646a8e7eadd347df015a952f31e..ee87c752a31af06b65a12e028ec2e2529bb01f59 100644 (file)
@@ -25,8 +25,8 @@ import encodings.idna    # type: ignore
 try:
     import idna          # type: ignore
     have_idna_2008 = True
-except ImportError:
-    have_idna_2008 = False  # pragma: no cover
+except ImportError:  # pragma: no cover
+    have_idna_2008 = False
 
 import dns.exception
 import dns.wiredata
@@ -218,7 +218,7 @@ class IDNA2008Codec(IDNACodec):
             if self.uts_46:
                 label = idna.uts46_remap(label, False, False)
             return _escapify(idna.ulabel(label))
-        except idna.IDNAError as e:
+        except (idna.IDNAError, UnicodeError) as e:
             raise IDNAException(idna_exception=e)
 
 _escaped = b'"().;\\@$'
@@ -303,7 +303,7 @@ def _maybe_convert_to_binary(label):
         return label
     if isinstance(label, str):
         return label.encode()
-    raise ValueError
+    raise ValueError  # pragma: no cover
 
 
 class Name: