Commit 522ffa25 authored by Éric Araujo's avatar Éric Araujo

Also close file descriptors from os.popen and subprocess.Popen

parent 41c052c4
...@@ -343,6 +343,7 @@ class bdist_rpm(Command): ...@@ -343,6 +343,7 @@ class bdist_rpm(Command):
src_rpm, non_src_rpm, spec_path) src_rpm, non_src_rpm, spec_path)
out = os.popen(q_cmd) out = os.popen(q_cmd)
try:
binary_rpms = [] binary_rpms = []
source_rpm = None source_rpm = None
while True: while True:
...@@ -360,6 +361,9 @@ class bdist_rpm(Command): ...@@ -360,6 +361,9 @@ class bdist_rpm(Command):
if status: if status:
raise DistutilsExecError("Failed to execute: %s" % repr(q_cmd)) raise DistutilsExecError("Failed to execute: %s" % repr(q_cmd))
finally:
out.close()
self.spawn(rpm_cmd) self.spawn(rpm_cmd)
if not self.dry_run: if not self.dry_run:
......
...@@ -263,10 +263,12 @@ def query_vcvarsall(version, arch="x86"): ...@@ -263,10 +263,12 @@ def query_vcvarsall(version, arch="x86"):
popen = subprocess.Popen('"%s" %s & set' % (vcvarsall, arch), popen = subprocess.Popen('"%s" %s & set' % (vcvarsall, arch),
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
try:
stdout, stderr = popen.communicate() stdout, stderr = popen.communicate()
if popen.wait() != 0: if popen.wait() != 0:
raise DistutilsPlatformError(stderr.decode("mbcs")) raise DistutilsPlatformError(stderr.decode("mbcs"))
finally:
popen.close()
stdout = stdout.decode("mbcs") stdout = stdout.decode("mbcs")
for line in stdout.split("\n"): for line in stdout.split("\n"):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment