-
Notifications
You must be signed in to change notification settings - Fork 14
Keys in bencode 3 are bytes, where in bencode 2 they were strings? #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@joachimmetz Yes, it seems like this is the intended behaviour. According to the bencode spec this is the correct behaviour. However, like you, I have come to rely on this library doing the conversion from bytes to strings. I was hoping the API would be changed to something like: import bencode
with open('test_data/bencode_transmission', 'rb') as f:
x = bencode.bread(f, try_decode=True, encoding='utf-8') This will allow people who want the previous behaviour to opt-in to it. |
@sximba thx for the context, though for me file/data format specification and Python API are 2 separate things. I understand that the file/data format defines byte streams to store textual strings, and that it appears that over time UTF-8 seems to have become the standard encoding for this 1, 2. However it is a bit surprising to me to, see the Python API change and seeing the Python 2 to 3 bytes to str changes, I'm left to wonder if this impactful API change is intentional or not. However this commit hints that this is intentional. A request to the project maintainers to reflect this in https://github.com/fuzeman/bencode.py#usage |
I'll add a flag to re-enable string decoding tomorrow (probably just an Should Moving forward pinning to a major version would be a good idea to avoid unexpected changes to the API. No breaking changes will be released in minor or patch releases. |
thx much appreciated
Noworries, this only affected tests for us. That's why the tests are there in the first place to catch changes. For production purposes we "pin" to specific versions. |
The library now includes a backwards-compatible `bencode` package, with the updated interface now available on the `bencodepy` package. #16
I've released v4.0.0 which now includes a The "Improved" API has been moved to
Great to hear. I was a bit concerned as requirements.txt in the referenced repository didn't have it pinned. |
thx, much appreciated. I'll have a look shortly. IMHO you can consider this issue closed |
Keys in bencode 3 are bytes, wheres in bencode 2 they were strings? Is this the intended behavior?
Bencode 2:
Bencode 3:
The text was updated successfully, but these errors were encountered: