]> granicus.if.org Git - python/commitdiff
Fix resource warning from patchcheck.py
authorÉric Araujo <merwok@netwok.org>
Mon, 22 Nov 2010 03:13:47 +0000 (03:13 +0000)
committerÉric Araujo <merwok@netwok.org>
Mon, 22 Nov 2010 03:13:47 +0000 (03:13 +0000)
Tools/scripts/patchcheck.py

index caffc9d4c44031bedccf9488ddcad3cf59c00696..e767edabd912cb9d0a985643ba17b4331e158da9 100644 (file)
@@ -45,13 +45,16 @@ def changed_files():
         sys.exit('need a checkout to get modified files')
 
     st = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
-    st.wait()
-    if vcs == 'hg':
-        return [x.decode().rstrip() for x in st.stdout]
-    else:
-        output = (x.decode().rstrip().rsplit(None, 1)[-1]
-                  for x in st.stdout if x[0] in b'AM')
+    try:
+        st.wait()
+        if vcs == 'hg':
+            return [x.decode().rstrip() for x in st.stdout]
+        else:
+            output = (x.decode().rstrip().rsplit(None, 1)[-1]
+                      for x in st.stdout if x[0] in b'AM')
         return set(path for path in output if os.path.isfile(path))
+    finally:
+        st.stdout.close()
 
 
 def report_modified_files(file_paths):