diff options
author | Éric Araujo <merwok@netwok.org> | 2010-11-05 23:51:56 (GMT) |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2010-11-05 23:51:56 (GMT) |
commit | bee5cef7dbff40734c347da5b93797e8db9103e8 (patch) | |
tree | 06dcc726207cfad3016f2b0f7c365fb9fe5b3cc6 /Lib/distutils/emxccompiler.py | |
parent | afb078dd2673d919ac3733104757c441f256f30f (diff) | |
download | cpython-bee5cef7dbff40734c347da5b93797e8db9103e8.zip cpython-bee5cef7dbff40734c347da5b93797e8db9103e8.tar.gz cpython-bee5cef7dbff40734c347da5b93797e8db9103e8.tar.bz2 |
Always close files in distutils code and tests (#10252).
Diffstat (limited to 'Lib/distutils/emxccompiler.py')
-rw-r--r-- | Lib/distutils/emxccompiler.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/distutils/emxccompiler.py b/Lib/distutils/emxccompiler.py index 62a4c5b..16dce53 100644 --- a/Lib/distutils/emxccompiler.py +++ b/Lib/distutils/emxccompiler.py @@ -270,8 +270,10 @@ def check_config_h(): # 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 as exc: # if we can't read this file, we cannot say it is wrong @@ -298,8 +300,10 @@ def get_versions(): 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, re.ASCII) if result: gcc_version = StrictVersion(result.group(1)) |