Merged revisions 86223-86224,86226,86234 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r86223 | eric.araujo | 2010-11-06 00:51:56 +0100 (sam., 06 nov. 2010) | 2 lines
Always close files in distutils code and tests (#10252).
........
r86224 | eric.araujo | 2010-11-06 00:58:34 +0100 (sam., 06 nov. 2010) | 2 lines
Add missing entry for r86223.
........
r86226 | eric.araujo | 2010-11-06 00:59:32 +0100 (sam., 06 nov. 2010) | 2 lines
Of course, I forgot one file in r86223.
........
r86234 | eric.araujo | 2010-11-06 03:10:32 +0100 (sam., 06 nov. 2010) | 2 lines
Also close file descriptors from os.popen and subprocess.Popen
........
diff --git a/Lib/distutils/emxccompiler.py b/Lib/distutils/emxccompiler.py
index f52e632..a017205 100644
--- a/Lib/distutils/emxccompiler.py
+++ b/Lib/distutils/emxccompiler.py
@@ -272,8 +272,10 @@
# It would probably better to read single lines to search.
# But we do this only once, and it is fast enough
f = open(fn)
- s = f.read()
- f.close()
+ try:
+ s = f.read()
+ finally:
+ f.close()
except IOError, exc:
# if we can't read this file, we cannot say it is wrong
@@ -300,8 +302,10 @@
gcc_exe = find_executable('gcc')
if gcc_exe:
out = os.popen(gcc_exe + ' -dumpversion','r')
- out_string = out.read()
- out.close()
+ try:
+ out_string = out.read()
+ finally:
+ out.close()
result = re.search('(\d+\.\d+\.\d+)',out_string)
if result:
gcc_version = StrictVersion(result.group(1))