Fix error messages for host not found when host
is passed in as bytes
#633
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.
open_tcp_stream can take
host
as either bytes or str, but the formatting for the error message when a host is not found depends on host being a string. When trying to connect to a non-existent host, if passed as a string I would get the exception:OSError: all attempts to connect to localhost:8081 failed
but when passed as bytes I would get the exception:
TypeError: a bytes-like object is required, not 'str'
This PR adds a single line to convert bytes to a string before running the rest of the function (and some tests).