diff options
author | Éric Araujo <merwok@netwok.org> | 2010-11-06 02:10:32 (GMT) |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2010-11-06 02:10:32 (GMT) |
commit | 5ac6d80c02a4da1f36652e6531da3c886df1f58c (patch) | |
tree | 994056f43b6edab6491515100f808213963430a8 /Lib/distutils/command | |
parent | 25b574138353df835c94039eecb0b9edefc1dede (diff) | |
download | cpython-5ac6d80c02a4da1f36652e6531da3c886df1f58c.zip cpython-5ac6d80c02a4da1f36652e6531da3c886df1f58c.tar.gz cpython-5ac6d80c02a4da1f36652e6531da3c886df1f58c.tar.bz2 |
Also close file descriptors from os.popen and subprocess.Popen
Diffstat (limited to 'Lib/distutils/command')
-rw-r--r-- | Lib/distutils/command/bdist_rpm.py | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py index 452f950..e2ae877 100644 --- a/Lib/distutils/command/bdist_rpm.py +++ b/Lib/distutils/command/bdist_rpm.py @@ -343,22 +343,26 @@ class bdist_rpm(Command): 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) |