[Python-checkins] r86274 - in python/branches/py3k/Lib/distutils: cygwinccompiler.py msvc9compiler.py

eric.araujo python-checkins at python.org
Sat Nov 6 16:57:53 CET 2010


Author: eric.araujo
Date: Sat Nov  6 16:57:52 2010
New Revision: 86274

Log:
Correct the fix for #10252: Popen objects have no close method.


Modified:
   python/branches/py3k/Lib/distutils/cygwinccompiler.py
   python/branches/py3k/Lib/distutils/msvc9compiler.py

Modified: python/branches/py3k/Lib/distutils/cygwinccompiler.py
==============================================================================
--- python/branches/py3k/Lib/distutils/cygwinccompiler.py	(original)
+++ python/branches/py3k/Lib/distutils/cygwinccompiler.py	Sat Nov  6 16:57:52 2010
@@ -377,7 +377,9 @@
     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

Modified: python/branches/py3k/Lib/distutils/msvc9compiler.py
==============================================================================
--- python/branches/py3k/Lib/distutils/msvc9compiler.py	(original)
+++ python/branches/py3k/Lib/distutils/msvc9compiler.py	Sat Nov  6 16:57:52 2010
@@ -267,21 +267,24 @@
         stdout, stderr = popen.communicate()
         if popen.wait() != 0:
             raise DistutilsPlatformError(stderr.decode("mbcs"))
-    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)
+        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.stdin.close()
+        popen.stdout.close()
+        popen.stderr.close()
 
     if len(result) != len(interesting):
         raise ValueError(str(list(result.keys())))


More information about the Python-checkins mailing list