[Python-checkins] cpython: test_gdb: fix ResourceWarning if the test is interrupted

victor.stinner python-checkins at python.org
Wed Sep 2 15:46:20 CEST 2015


https://hg.python.org/cpython/rev/c664f58a50f5
changeset:   97581:c664f58a50f5
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Wed Sep 02 15:46:00 2015 +0200
summary:
  test_gdb: fix ResourceWarning if the test is interrupted

files:
  Lib/test/test_gdb.py |  8 +++++---
  1 files changed, 5 insertions(+), 3 deletions(-)


diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -63,9 +63,11 @@
     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:

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list