Commit 3ae44b5e authored by Raul Tambre's avatar Raul Tambre Committed by Commit Bot

js_modulizer: Fix writing to file on Python 3

Since the file is now written in binary mode, newline translation is no longer a concern and is consistent across platforms.

[14/39932] ACTION //chrome/browser/resources/settings:modulize(//build/toolchain/win:win_clang_x64)
Traceback (most recent call last):
  File "../../ui/webui/resources/tools/js_modulizer.py", line 154, in <module>
    main(sys.argv[1:])
  File "../../ui/webui/resources/tools/js_modulizer.py", line 150, in main
    ProcessFile(os.path.join(in_folder, f), out_folder, namespace_rewrites)
  File "../../ui/webui/resources/tools/js_modulizer.py", line 128, in ProcessFile
    f.write(unicode(l, 'utf-8'))
NameError: name 'unicode' is not defined

Bug: 941669
Change-Id: I7aa0aa834944e4505f9045026e3d32315740140b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2033509
Auto-Submit: Raul Tambre <raul@tambre.ee>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Raul Tambre <raul@tambre.ee>
Cr-Commit-Position: refs/heads/master@{#738256}
parent 2dabc967
......@@ -123,9 +123,9 @@ def ProcessFile(filename, out_folder, namespace_rewrites):
# Reconstruct file.
# Specify the newline character so that the exact same file is generated
# across platforms.
with io.open(os.path.join(out_folder, out_filename), 'w', newline='\n') as f:
with io.open(os.path.join(out_folder, out_filename), 'wb') as f:
for l in lines:
f.write(unicode(l, 'utf-8'))
f.write(l.encode('utf-8'))
return
def main(argv):
......
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