Skip to content

Commit 632cce2

Browse files
committed
chore: simplify run-tests by using text mode for subprocess
1 parent 770f82c commit 632cce2

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()))
@@ -99,7 +99,7 @@ def run(compiler_executable: str, compiler_args: list[str]) -> tuple[int, str, s
9999
cmd = [compiler_executable, *compiler_args]
100100

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

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

115115

0 commit comments

Comments
 (0)