Commit eaf0e057 authored by Dirk Pranke's avatar Dirk Pranke Committed by Chromium LUCI CQ

Fix Python3 issue with wayland_protocol_codegen.py.

The script had a couple of issues that crop up with
Python3's str/bytes/unicode changes.

Bug: 1168342
Change-Id: Ic1ff68d099245bcf5b39382bc5f3919fd13609a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2638785Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Cr-Commit-Position: refs/heads/master@{#845408}
parent 1d8e7de3
...@@ -68,7 +68,8 @@ def clang_format_source_text(source_text, clang_format_path, ...@@ -68,7 +68,8 @@ def clang_format_source_text(source_text, clang_format_path,
[clang_format_path, '--assume-filename', effective_filename], [clang_format_path, '--assume-filename', effective_filename],
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
stdout=subprocess.PIPE) stdout=subprocess.PIPE)
stdout_output, stderr_output = proc.communicate(input=source_text) stdout_output, stderr_output = proc.communicate(
input=source_text.encode('utf8'))
retcode = proc.wait() retcode = proc.wait()
if retcode != 0: if retcode != 0:
raise CalledProcessError(retcode, raise CalledProcessError(retcode,
...@@ -80,11 +81,11 @@ def write_if_changed(source_text, output): ...@@ -80,11 +81,11 @@ def write_if_changed(source_text, output):
# type: (str, str) -> None # type: (str, str) -> None
"""Writes source_text to output, but only if different.""" """Writes source_text to output, but only if different."""
if os.path.exists(output): if os.path.exists(output):
with open(output, 'rt') as infile: with open(output, 'rb') as infile:
if infile.read() == source_text: if infile.read() == source_text:
return return
with open(output, 'wt') as outfile: with open(output, 'wb') as outfile:
outfile.write(source_text) outfile.write(source_text)
......
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