Skip to content

Commit 34ec723

Browse files
committed
chore: simplify run-tests by using text mode for subprocess
1 parent 0645fd5 commit 34ec723

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
@@ -10,7 +10,7 @@
1010

1111
def cleanup(out: str) -> str:
1212
parts = []
13-
for line in out.decode('utf-8').splitlines():
13+
for line in out.splitlines():
1414
if len(line) > 1 and line[0] == '#':
1515
continue
1616
parts.append("".join(line.split()))
@@ -108,7 +108,7 @@ def run(compiler_executable: str, compiler_args: List[str]) -> Tuple[int, str, s
108108
cmd = [compiler_executable, *compiler_args]
109109

110110
try:
111-
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as process:
111+
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, encoding="utf-8") as process:
112112
stdout, stderr = process.communicate()
113113
exit_code = process.returncode
114114
except FileNotFoundError as e:
@@ -117,8 +117,8 @@ def run(compiler_executable: str, compiler_args: List[str]) -> Tuple[int, str, s
117117
except Exception as e:
118118
return (1, "", f"{e}")
119119

120-
output = cleanup(stdout) # bytes -> str via cleanup
121-
error = (stderr or b"").decode("utf-8", errors="replace").strip()
120+
output = cleanup(stdout)
121+
error = (stderr or "").strip()
122122
return (exit_code, output, error)
123123

124124

0 commit comments

Comments
 (0)