]> granicus.if.org Git - python/commitdiff
Correct the fix for #10252: Popen objects have no close method.
authorÉric Araujo <merwok@netwok.org>
Sat, 6 Nov 2010 15:57:52 +0000 (15:57 +0000)
committerÉric Araujo <merwok@netwok.org>
Sat, 6 Nov 2010 15:57:52 +0000 (15:57 +0000)
Lib/distutils/cygwinccompiler.py
Lib/distutils/msvc9compiler.py

index 95fa3ed3c8cba315903e5c8a16f91c5fe4b4a690..5676e91a79a36beacbdcea1a93a1e332998f13e6 100644 (file)
@@ -377,7 +377,9 @@ def _find_exe_version(cmd):
     try:
         out_string = out.read()
     finally:
-        out.close()
+        out.stdin.close()
+        out.stdout.close()
+        out.stderr.close()
     result = RE_VERSION.search(out_string)
     if result is None:
         return None
index 6d7825df86ea32e7f814f40ae65710185cf28102..488524db9100802f1aaf9d4cdd708c7ad55899f2 100644 (file)
@@ -267,21 +267,24 @@ def query_vcvarsall(version, arch="x86"):
         stdout, stderr = popen.communicate()
         if popen.wait() != 0:
             raise DistutilsPlatformError(stderr.decode("mbcs"))
+
+        stdout = stdout.decode("mbcs")
+        for line in stdout.split("\n"):
+            line = Reg.convert_mbcs(line)
+            if '=' not in line:
+                continue
+            line = line.strip()
+            key, value = line.split('=', 1)
+            key = key.lower()
+            if key in interesting:
+                if value.endswith(os.pathsep):
+                    value = value[:-1]
+                result[key] = removeDuplicates(value)
+
     finally:
-        popen.close()
-
-    stdout = stdout.decode("mbcs")
-    for line in stdout.split("\n"):
-        line = Reg.convert_mbcs(line)
-        if '=' not in line:
-            continue
-        line = line.strip()
-        key, value = line.split('=', 1)
-        key = key.lower()
-        if key in interesting:
-            if value.endswith(os.pathsep):
-                value = value[:-1]
-            result[key] = removeDuplicates(value)
+        popen.stdin.close()
+        popen.stdout.close()
+        popen.stderr.close()
 
     if len(result) != len(interesting):
         raise ValueError(str(list(result.keys())))