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/dist.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/dist.py')
-rw-r--r-- | Lib/distutils/dist.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py index 1c1ea47..01f1f1c 100644 --- a/Lib/distutils/dist.py +++ b/Lib/distutils/dist.py @@ -1012,9 +1012,11 @@ class DistributionMetadata: def write_pkg_info(self, base_dir): """Write the PKG-INFO file into the release tree. """ - pkg_info = open( os.path.join(base_dir, 'PKG-INFO'), 'w') - self.write_pkg_file(pkg_info) - pkg_info.close() + pkg_info = open(os.path.join(base_dir, 'PKG-INFO'), 'w') + try: + self.write_pkg_file(pkg_info) + finally: + pkg_info.close() def write_pkg_file(self, file): """Write the PKG-INFO format data to a file object. |