Skip to content

Conversation

@jgoclawski
Copy link
Member

@jgoclawski jgoclawski commented Mar 7, 2025

Handle invalid use of the library.

When TypeError: can't concat str to bytes happens it's probably because something like this was used:

api.get_binary_resource('/').call('ping', { 'address': '192.168.56.1', 'count': '4' })

When using get_binary_resource then the values should be bytes, they should be encoded. In this case, let the library handle encoding/decoding and use get_resource instead:

api.get_resource('/').call('ping', { 'address': '192.168.56.1', 'count': '4' })

The first version (with get_binary_resource) will now work, thanks to this PR, but emit a warning.

Fixes: #39
Supersedes: #65

Handle invalid use of the library.
@jgoclawski jgoclawski force-pushed the fix_concat_str_to_bytes branch from 778c411 to 4728e5c Compare March 7, 2025 10:28
@jgoclawski jgoclawski merged commit 893d7ec into master Mar 7, 2025
4 checks passed
@jgoclawski jgoclawski deleted the fix_concat_str_to_bytes branch March 7, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: can't concat str to bytes?

2 participants