Merge pull request #15710 from acooks-at-bda/bugfix/fix-indent-byte-handling

tools/indent.py: fix encoded byte stream handling
This commit is contained in:
Donald Sharp 2024-04-11 08:25:15 -04:00 committed by GitHub
commit 5139ce8a3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -34,13 +34,13 @@ def wrap_file(fn):
ci = subprocess.Popen( ci = subprocess.Popen(
["clang-format"], stdin=subprocess.PIPE, stdout=subprocess.PIPE ["clang-format"], stdin=subprocess.PIPE, stdout=subprocess.PIPE
) )
stdout, ign = ci.communicate(text) stdout, ign = ci.communicate(text.encode("utf-8"))
ci.wait() ci.wait()
if ci.returncode != 0: if ci.returncode != 0:
raise IOError("clang-format returned %d" % (ci.returncode)) raise IOError("clang-format returned %d" % (ci.returncode))
# remove the bits we inserted above # remove the bits we inserted above
final = clean_re.sub("", stdout) final = clean_re.sub("", stdout.decode("utf-8"))
tmpname = fn + ".indent" tmpname = fn + ".indent"
with open(tmpname, "w") as ofd: with open(tmpname, "w") as ofd: