99
1010def 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