[Python-checkins] r86234 - in python/branches/py3k/Lib/distutils: command/bdist_rpm.py msvc9compiler.py
eric.araujo
python-checkins at python.org
Sat Nov 6 03:10:32 CET 2010
Author: eric.araujo
Date: Sat Nov 6 03:10:32 2010
New Revision: 86234
Log:
Also close file descriptors from os.popen and subprocess.Popen
Modified:
python/branches/py3k/Lib/distutils/command/bdist_rpm.py
python/branches/py3k/Lib/distutils/msvc9compiler.py
Modified: python/branches/py3k/Lib/distutils/command/bdist_rpm.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/bdist_rpm.py (original)
+++ python/branches/py3k/Lib/distutils/command/bdist_rpm.py Sat Nov 6 03:10:32 2010
@@ -343,22 +343,26 @@
src_rpm, non_src_rpm, spec_path)
out = os.popen(q_cmd)
- binary_rpms = []
- source_rpm = None
- while True:
- line = out.readline()
- if not line:
- break
- l = line.strip().split()
- assert(len(l) == 2)
- binary_rpms.append(l[1])
- # The source rpm is named after the first entry in the spec file
- if source_rpm is None:
- source_rpm = l[0]
-
- status = out.close()
- if status:
- raise DistutilsExecError("Failed to execute: %s" % repr(q_cmd))
+ try:
+ binary_rpms = []
+ source_rpm = None
+ while True:
+ line = out.readline()
+ if not line:
+ break
+ l = line.strip().split()
+ assert(len(l) == 2)
+ binary_rpms.append(l[1])
+ # The source rpm is named after the first entry in the spec file
+ if source_rpm is None:
+ source_rpm = l[0]
+
+ status = out.close()
+ if status:
+ raise DistutilsExecError("Failed to execute: %s" % repr(q_cmd))
+
+ finally:
+ out.close()
self.spawn(rpm_cmd)
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 03:10:32 2010
@@ -263,10 +263,12 @@
popen = subprocess.Popen('"%s" %s & set' % (vcvarsall, arch),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
-
- stdout, stderr = popen.communicate()
- if popen.wait() != 0:
- raise DistutilsPlatformError(stderr.decode("mbcs"))
+ try:
+ 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"):
More information about the Python-checkins
mailing list