Skip to content

Commit 8d9228d

Browse files
committed
chore: simplify run-tests by using text mode for subprocess
1 parent 645062b commit 8d9228d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

run-tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
def cleanup(out: str) -> str:
1111
parts = []
12-
for line in out.decode('utf-8').splitlines():
12+
for line in out.splitlines():
1313
if len(line) > 1 and line[0] == '#':
1414
continue
1515
parts.append("".join(line.split()))
@@ -100,7 +100,7 @@ def run(compiler_executable: str, compiler_args: list[str]) -> tuple[int, str, s
100100
compiler_cmd.extend(compiler_args)
101101

102102
try:
103-
with subprocess.Popen(compiler_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as process:
103+
with subprocess.Popen(compiler_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, encoding="utf-8") as process:
104104
stdout, stderr = process.communicate()
105105
exit_code = process.returncode
106106
except FileNotFoundError as e:
@@ -109,8 +109,8 @@ def run(compiler_executable: str, compiler_args: list[str]) -> tuple[int, str, s
109109
except Exception as e:
110110
return (1, "", f"{e}")
111111

112-
output = cleanup(stdout) # bytes -> str via cleanup
113-
error = (stderr or b"").decode("utf-8", errors="replace").strip()
112+
output = cleanup(stdout)
113+
error = (stderr or "").strip()
114114
return (exit_code, output, error)
115115

116116

0 commit comments

Comments
 (0)