Commit a311cf92 authored by Raul Tambre's avatar Raul Tambre Committed by Commit Bot

mojo: Don't open concatenation files as binary

In Python 3 operations on files opened in binary mode have to be done with bytestrings.
Python 2 doesn't care, so it happens to work.
Don't open the files in binary mode, as they aren't used as such.

Traceback (most recent call last):
  File "../../mojo/public/tools/bindings/concatenate_and_replace_closure_exports.py", line 73, in <module>
    main()
  File "../../mojo/public/tools/bindings/concatenate_and_replace_closure_exports.py", line 70, in main
    exit(0 if ConcatenateAndReplaceExports(args) else 1)
  File "../../mojo/public/tools/bindings/concatenate_and_replace_closure_exports.py", line 58, in ConcatenateAndReplaceExports
    FilterLine(filename, line, target)
  File "../../mojo/public/tools/bindings/concatenate_and_replace_closure_exports.py", line 30, in FilterLine
    if line.startswith("goog.require"):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

Bug: 941669
Change-Id: Ic373069e87707eb28ca1b3bf60556f066c19c5d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2081413
Auto-Submit: Raul Tambre <raul@tambre.ee>
Commit-Queue: Ken Rockot <rockot@google.com>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#746169}
parent c67836e9
...@@ -51,9 +51,9 @@ def ConcatenateAndReplaceExports(filenames): ...@@ -51,9 +51,9 @@ def ConcatenateAndReplaceExports(filenames):
return False return False
try: try:
with open(filenames[-1], "wb") as target: with open(filenames[-1], "w") as target:
for filename in filenames[:-1]: for filename in filenames[:-1]:
with open(filename, "rb") as current: with open(filename, "r") as current:
for line in current.readlines(): for line in current.readlines():
FilterLine(filename, line, target) FilterLine(filename, line, target)
return True return True
......
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