Remove BytesWarnings in client.py by putting u() around every hexlify, other BytesWarnings fixes #1661
+16
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I run python in an environment where BytesWarnings are enabled and promoted to errors. This was really helpful during py2->3 transitioning, and still helps prevent misuse of bytes as strings.
I'd like to keep doing this while using Paramiko, but I hit BytesWarnings when doing so. I looked at related issues for paramiko, and they've previously been fixed by putting a u() around the offending bytes. This is appropriate for calls to hexlify that are then passed to format(), since hexlify returns the bytes for the ASCII-encoded hex rep of the input.
This is what was done for the same kind of issue previously: #1074
I also fixed the same kind of issue, in auth_client.py, reported at:
#1593
This should also close the issue 728 linked below. The issue requested a string-ish hex-digest, which would be more dramatic and risky for a wholesale transition, since there could be clients that still need the bytes-ish one. But the u() around the hexlifys going to format safely resolves being able to run with -bb.:
#726
I went ahead and found the rest of the uses of hexlify that were exclusively passed to format/print, and fixed similarly. I left other uses of hexllify alone, as there are definitely still places, e.g. tests, that fully expect bytes back.