Skip to content

Commit

Permalink
tools/indent.py: fix encoded byte stream handling
Browse files Browse the repository at this point in the history
Python subprocess communication now operates on bytes, not strings.

Signed-off-by: Andrew Cooks <[email protected]>
  • Loading branch information
acooks committed Apr 10, 2024
1 parent 8cfa3b5 commit e443644
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/indent.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ def wrap_file(fn):
ci = subprocess.Popen(
["clang-format"], stdin=subprocess.PIPE, stdout=subprocess.PIPE
)
stdout, ign = ci.communicate(text)
stdout, ign = ci.communicate(text.encode("utf-8"))
ci.wait()
if ci.returncode != 0:
raise IOError("clang-format returned %d" % (ci.returncode))

# remove the bits we inserted above
final = clean_re.sub("", stdout)
final = clean_re.sub("", stdout.decode("utf-8"))

tmpname = fn + ".indent"
with open(tmpname, "w") as ofd:
Expand Down

0 comments on commit e443644

Please sign in to comment.