test_gdb: fix ResourceWarning if the test is interrupted

This commit is contained in:
Victor Stinner 2015-09-02 15:46:00 +02:00
parent 6dad8f8962
commit e801c36037
1 changed files with 5 additions and 3 deletions

View File

@ -63,9 +63,11 @@ def run_gdb(*args, **env_vars):
base_cmd = ('gdb', '--batch', '-nx') base_cmd = ('gdb', '--batch', '-nx')
if (gdb_major_version, gdb_minor_version) >= (7, 4): if (gdb_major_version, gdb_minor_version) >= (7, 4):
base_cmd += ('-iex', 'add-auto-load-safe-path ' + checkout_hook_path) base_cmd += ('-iex', 'add-auto-load-safe-path ' + checkout_hook_path)
out, err = subprocess.Popen(base_cmd + args, proc = subprocess.Popen(base_cmd + args,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, stdout=subprocess.PIPE,
).communicate() stderr=subprocess.PIPE, env=env)
with proc:
out, err = proc.communicate()
return out.decode('utf-8', 'replace'), err.decode('utf-8', 'replace') return out.decode('utf-8', 'replace'), err.decode('utf-8', 'replace')
# Verify that "gdb" was built with the embedded python support enabled: # Verify that "gdb" was built with the embedded python support enabled: