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/core.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/core.py')
-rw-r--r-- | Lib/distutils/core.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/distutils/core.py b/Lib/distutils/core.py index 6e48920..fd2a43d 100644 --- a/Lib/distutils/core.py +++ b/Lib/distutils/core.py @@ -215,7 +215,11 @@ def run_setup (script_name, script_args=None, stop_after="run"): sys.argv[0] = script_name if script_args is not None: sys.argv[1:] = script_args - exec(open(script_name).read(), g, l) + f = open(script_name) + try: + exec(f.read(), g, l) + finally: + f.close() finally: sys.argv = save_argv _setup_stop_after = None |