grit: c_format: rework how we build the escaped string
Python 3 doesn't support string_escape on bytes. It doesn't have an official supported form for this currently either. It could be done ad-hoc (iterate over every byte and build up the string ourselves), but it turns out the codecs module has an escape_encode helper that does what we need with a bit of effort. Also cleanup the associated unittest while we're here. It was mixing bytes & string data inline and expecting it to be interpreted as UTF8 encoding. Python 3 didn't like this at all. Make it a proper unicode string and use \u sequences to get the codepoints we want. Bug: 983071 Test: `./grit/test_suite_all.py` passes Change-Id: I1c4de0e3ab5c129d4999d6685887a2c54bd7ab9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1755388 Commit-Queue: Mike Frysinger <vapier@chromium.org> Reviewed-by:Robert Flack <flackr@chromium.org> Cr-Commit-Position: refs/heads/master@{#687323}
Showing
Please register or sign in to comment