summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-09-02 13:46:00 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-09-02 13:46:00 (GMT)
commite801c36037bf3875de0ecbb79c9f9ba8938027da (patch)
tree32869ba8b9013991a989e691bec105908a3047c9
parent6dad8f89623e588f486d069b7a336c1430c3c147 (diff)
downloadcpython-e801c36037bf3875de0ecbb79c9f9ba8938027da.zip
cpython-e801c36037bf3875de0ecbb79c9f9ba8938027da.tar.gz
cpython-e801c36037bf3875de0ecbb79c9f9ba8938027da.tar.bz2
test_gdb: fix ResourceWarning if the test is interrupted
-rw-r--r--Lib/test/test_gdb.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index 193c97a..a51b552 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -63,9 +63,11 @@ def run_gdb(*args, **env_vars):
base_cmd = ('gdb', '--batch', '-nx')
if (gdb_major_version, gdb_minor_version) >= (7, 4):
base_cmd += ('-iex', 'add-auto-load-safe-path ' + checkout_hook_path)
- out, err = subprocess.Popen(base_cmd + args,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env,
- ).communicate()
+ proc = subprocess.Popen(base_cmd + args,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, env=env)
+ with proc:
+ out, err = proc.communicate()
return out.decode('utf-8', 'replace'), err.decode('utf-8', 'replace')
# Verify that "gdb" was built with the embedded python support enabled: