-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not assume that binary addresses are valid unicode
On lookup failure we would previously assume that binary addresses are valid unicode when constructing exception messages. With python/cpython#105375 which appeared e.g., in python-3.11.9 this starts to cause failures as invalid unicode is now more consistently rejected; e.g., in the test `pysubnettree.lookup` we construct a binary address `1.3.3.255` which corresponds to `b'\x01\x03\x03\xff'` which is not valid unicode. With this patch we set messages for `KeyError` from a `bytes` object instead of a `str`, so that user's see e.g., KeyError: b'1:3:3::3' instead of the previous KeyError: '1:3:3::3' This should still provide all the information necessary while working with our interface which allows both `str` and `bytes` inputs. The changes to `SubnetTree_wrap.cc` are generated automatically with swig-3.0.12.
- Loading branch information
Showing
2 changed files
with
35 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters