Skip to content

Commit 798d7fb

Browse files
committed
Merge 3.5 (script_helper)
2 parents 435eaf4 + 7e6977a commit 798d7fb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Lib/test/support/script_helper.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ def run_python_until_end(*args, **env_vars):
8383
env = {}
8484
env.update(env_vars)
8585
cmd_line.extend(args)
86-
p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
86+
proc = subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
8787
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
8888
env=env)
89-
try:
90-
out, err = p.communicate()
91-
finally:
92-
subprocess._cleanup()
93-
p.stdout.close()
94-
p.stderr.close()
95-
rc = p.returncode
89+
with proc:
90+
try:
91+
out, err = proc.communicate()
92+
finally:
93+
proc.kill()
94+
subprocess._cleanup()
95+
rc = proc.returncode
9696
err = strip_python_stderr(err)
9797
return _PythonRunResult(rc, out, err), cmd_line
9898

0 commit comments

Comments
 (0)