1010
1111def 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 ()))
@@ -100,7 +100,7 @@ def run(compiler_executable: str, compiler_args: List[str]) -> Tuple[int, str, s
100100 cmd = [compiler_executable , * compiler_args ]
101101
102102 try :
103- with subprocess .Popen (cmd , stdout = subprocess .PIPE , stderr = subprocess .PIPE ) as process :
103+ with subprocess .Popen (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