@@ -186,8 +186,8 @@ def write_wast(filename, wast, asserts=[]):
186186 o .write (wast + '\n ' .join (asserts ))
187187
188188
189- # Hack to allow subprocess.Popen with stdout/stderr to StringIO, which doesn't have a fileno and doesn't work otherwise
190- def _process_communicate (* args , ** kwargs ):
189+ # Hack to allow subprocess with stdout/stderr to StringIO, which doesn't have a fileno and doesn't work otherwise
190+ def _subprocess_run (* args , ** kwargs ):
191191 overwrite_stderr = "stderr" in kwargs and isinstance (kwargs ["stderr" ], io .StringIO )
192192 overwrite_stdout = "stdout" in kwargs and isinstance (kwargs ["stdout" ], io .StringIO )
193193
@@ -198,15 +198,14 @@ def _process_communicate(*args, **kwargs):
198198 stderr_fd = kwargs ["stderr" ]
199199 kwargs ["stderr" ] = subprocess .PIPE
200200
201- proc = subprocess .Popen (* args , ** kwargs )
202- out , err = proc .communicate ()
201+ proc = subprocess .run (* args , ** kwargs )
203202
204203 if overwrite_stdout :
205- stdout_fd .write (out )
204+ stdout_fd .write (proc . stdout )
206205 if overwrite_stderr :
207- stderr_fd .write (err )
206+ stderr_fd .write (proc . stderr )
208207
209- return out , err , proc .returncode
208+ return proc . stdout , proc . stderr , proc .returncode
210209
211210
212211def run_command (cmd , expected_status = 0 , stdout = None , stderr = None ,
@@ -222,7 +221,7 @@ def run_command(cmd, expected_status=0, stdout=None, stderr=None,
222221 stderr = subprocess .PIPE
223222 print ('executing: ' , ' ' .join (cmd ), file = stdout )
224223
225- out , err , code = _process_communicate (cmd , stdout = subprocess .PIPE , stderr = stderr , universal_newlines = True , encoding = 'UTF-8' )
224+ out , err , code = _subprocess_run (cmd , stdout = subprocess .PIPE , stderr = stderr , encoding = 'UTF-8' )
226225
227226 if expected_status is not None and code != expected_status :
228227 raise Exception (f"run_command `{ ' ' .join (cmd )} ` failed ({ code } ) { err or '' } " )
0 commit comments