ulp_serialized_to_static_c.py: Python 3 compatibility
* Normal strings can't be used for operations with a file opened in binary mode. Fixed by using bytestrings. * Due to being opened in binary mode bytes are read instead of strings in Python 3. Thus use ord() only in Python 2. Still works with Python 2. Fixed errors: Traceback (most recent call last): File "../../components/language/content/browser/ulp_language_code_locator/ulp_serialized_to_static_c.py", line 79, in <module> Main() File "../../components/language/content/browser/ulp_language_code_locator/ulp_serialized_to_static_c.py", line 72, in Main models = [ReadSerializedData(data_path) for data_path in args.data] File "../../components/language/content/browser/ulp_language_code_locator/ulp_serialized_to_static_c.py", line 72, in <listcomp> models = [ReadSerializedData(data_path) for data_path in args.data] File "../../components/language/content/browser/ulp_language_code_locator/ulp_serialized_to_static_c.py", line 28, in ReadSerializedData linebreak = data.index('\n') TypeError: argument should be integer or bytes-like object, not 'str' Traceback (most recent call last): File "../../components/language/content/browser/ulp_language_code_locator/ulp_serialized_to_static_c.py", line 82, in <module> Main() File "../../components/language/content/browser/ulp_language_code_locator/ulp_serialized_to_static_c.py", line 75, in Main models = [ReadSerializedData(data_path) for data_path in args.data] File "../../components/language/content/browser/ulp_language_code_locator/ulp_serialized_to_static_c.py", line 75, in <listcomp> models = [ReadSerializedData(data_path) for data_path in args.data] File "../../components/language/content/browser/ulp_language_code_locator/ulp_serialized_to_static_c.py", line 37, in ReadSerializedData tree_serialized = [ File "../../components/language/content/browser/ulp_language_code_locator/ulp_serialized_to_static_c.py", line 38, in <listcomp> sum((ord(tree_bytes[i+b]) << (8*b)) if i+b < len(tree_bytes) else 0 File "../../components/language/content/browser/ulp_language_code_locator/ulp_serialized_to_static_c.py", line 38, in <genexpr> sum((ord(tree_bytes[i+b]) << (8*b)) if i+b < len(tree_bytes) else 0 TypeError: ord() expected string of length 1, but int found Bug: 941669 Change-Id: Ib540c21eb63fc9407596a49e5114b8ab7e9a5a10 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857123 Auto-Submit: Raul Tambre <raul@tambre.ee> Commit-Queue: anthonyvd <anthonyvd@chromium.org> Reviewed-by:Alexandre Frechette <frechette@chromium.org> Reviewed-by:
anthonyvd <anthonyvd@chromium.org> Cr-Commit-Position: refs/heads/master@{#712138}
Showing
Please register or sign in to comment