Closed banteg closed 1 year ago
I've updated the class as described and adjusted testing, let me know if you have any thoughts. I'll work on an example for the docs tomorrow.
Not too complex, got it added. User can now call the existing string
decoder like you wrote, or add multiple StringDecoders
with different behaviors to the registry. The default behavior has been returned to the default strict
.
Not sure about the docs location - it could be appropriate to put it in the Decoding section too. Thoughts?
You are correct, the defaults were not updated, I must not have saved properly. I've added a test to make sure of it now.
I've removed the errors
argument from the top-level decode
function as I don't see a way forward for it, but we can discuss further.
Thanks @banteg !
What was wrong?
decoding was failing for some malformed strings.
you can see an example of this if you try to decode logs from mainnet transaction
0x505870232ebd6cefd2a59c760924664212f72759e58fd2df82d61b67ffe0dd75
.it should be possible to read the useful data even from a malformed input.
How was it fixed?
added
errors="surrogateescape"
todecode
as suggested here https://peps.python.org/pep-0383/i deliberately skipped adding the same to
encode
because passing an unencodable string usually signifies a user error.To-Do
[x] Clean up commit history
[x] Add entry to the release notes
Cute Animal Picture