Commit a0ca4c05 authored by Adam Langley's avatar Adam Langley Committed by Commit Bot

Parse .mojom as UTF-8.

The parser called on the changed line demands a Python |str| type, but
|contents| here can be a |unicode|. The |str| converter in Python 2
assumes an ASCII encoding and thus throws an exception if any characters
are > 127. This means that any changed .mojo files that contain non-ASCII
characters cause a presubmit error. One can't remove those characters
either because the presubmit parses the previous version of the file
too. Thus all changes to .mojo file with non-ASCII characters are
blocked without this.

Change-Id: I887890590c8ad97a4fac60d19a8bebce439abacc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2223973
Commit-Queue: Adam Langley <agl@chromium.org>
Auto-Submit: Adam Langley <agl@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#773768}
parent 6a9c5775
...@@ -63,7 +63,7 @@ def _ValidateDelta(root, delta): ...@@ -63,7 +63,7 @@ def _ValidateDelta(root, delta):
with open(os.path.join(root, mojom)) as f: with open(os.path.join(root, mojom)) as f:
contents = ''.join(f.readlines()) contents = ''.join(f.readlines())
ast = parser.Parse(str(contents), mojom) ast = parser.Parse(contents.encode('utf-8'), mojom)
for imp in ast.import_list: for imp in ast.import_list:
parseMojom(imp.import_filename, file_overrides, override_modules) parseMojom(imp.import_filename, file_overrides, override_modules)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment