Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Serializing a
bytesvalue converted it to a string withraw_unicode_escape, which treats literal\uXXXX/\UXXXXXXXXbyte sequences as escapes. As a result,br'\u00ff'came back asb'\xff', and some invalid sequences such asbr'\u123'orbr'\uZZZZ'raisedUnicodeDecodeErrorduringdump_json.Serialization now uses
latin-1, which maps each byte to one character. The reader is unchanged and still usesraw_unicode_escape, so the schema stays the same and existing documents load as before. For bytes containing backslash-u sequences, the stored string now keeps those characters as written (for examplebr'\u1234'is stored as the six characters\u1234). Both the old and new forms read back as the same bytes.Adds regression coverage for:
Config→dump_json→load_json→buildfor empty, ASCII, all 256 byte values, and five escape-like inputs;br'\u1234'.Testing (local, Linux, Python 3.12):
pytest --ignore=fiddle/_src/extensions/seqio_test.py -q fiddle: 1117 passed, 4 skipped, 330 subtests passed.pytype -j 4 fiddle/_src/experimental/serialization.py: no errors.