Skip to content

Commit

Permalink
fixup! Do not assume that binary addresses are valid unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed May 8, 2024
1 parent d3e0afd commit 7fad27d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions testing/pysubnettree/lookup.test
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ def do_tests(binarymode):
try:
if t[v4("1.3.3.255")]: pass
testcase(False, "lookup should throw exception")
except KeyError:
pass
except KeyError as e:
# We expect a `KeyError` which reports the key. Since above address
# encodes to invalid unicode we'd expect to see the raw bytes as error
# message in binary mode.
assert str(e) == r"b'\x01\x03\x03\xff'" if binarymode else r"b'1.3.3.255'"

try:
if t[v6("1:3:3::3")]: pass
Expand Down

0 comments on commit 7fad27d

Please sign in to comment.