When decoding strings, added possibility to choose how to manage errors #605
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.
Context:
I'm using your library since the public API of a game is using protobuf. I'm builing a bot over these API.
While parsing a Message received from this API, I noticed I was getting an exception
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 82: invalid continuation byte
. This beacuse the API returned a somehow broken Message, with not UTF8 characters in it. The game is however built in C++, so the behaviour is different, causing no issue in the game but an exception in my bot.By default, Python bytes.decode method is strict, so it crashes in case it goes in errror. This PR aim to change this behaviour by adding a parameter that an user can modify in order to ignore or replace the non UTF8 characters.
Regarding the test case, I could provide the bytes and the Message definition I've used, however it contains a lot of other non relevant fields, can I somehow reduce it to only have the broken part?
Regarding the documentation, I'm not native english speaker/writer so it's probably better if I don't update it myself.
Summary
Checklist