Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8bdbe9c

Browse files
committed
Correct the fix for #10252: Popen objects have no close method.
1 parent e7cf954 commit 8bdbe9c

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

Lib/distutils/cygwinccompiler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,9 @@ def _find_exe_version(cmd):
377377
try:
378378
out_string = out.read()
379379
finally:
380-
out.close()
380+
out.stdin.close()
381+
out.stdout.close()
382+
out.stderr.close()
381383
result = RE_VERSION.search(out_string)
382384
if result is None:
383385
return None

Lib/distutils/msvc9compiler.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -267,21 +267,24 @@ def query_vcvarsall(version, arch="x86"):
267267
stdout, stderr = popen.communicate()
268268
if popen.wait() != 0:
269269
raise DistutilsPlatformError(stderr.decode("mbcs"))
270+
271+
stdout = stdout.decode("mbcs")
272+
for line in stdout.split("\n"):
273+
line = Reg.convert_mbcs(line)
274+
if '=' not in line:
275+
continue
276+
line = line.strip()
277+
key, value = line.split('=', 1)
278+
key = key.lower()
279+
if key in interesting:
280+
if value.endswith(os.pathsep):
281+
value = value[:-1]
282+
result[key] = removeDuplicates(value)
283+
270284
finally:
271-
popen.close()
272-
273-
stdout = stdout.decode("mbcs")
274-
for line in stdout.split("\n"):
275-
line = Reg.convert_mbcs(line)
276-
if '=' not in line:
277-
continue
278-
line = line.strip()
279-
key, value = line.split('=', 1)
280-
key = key.lower()
281-
if key in interesting:
282-
if value.endswith(os.pathsep):
283-
value = value[:-1]
284-
result[key] = removeDuplicates(value)
285+
popen.stdin.close()
286+
popen.stdout.close()
287+
popen.stderr.close()
285288

286289
if len(result) != len(interesting):
287290
raise ValueError(str(list(result.keys())))

0 commit comments

Comments
 (0)