summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/dist.py
diff options
context:
space:
mode:
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)
commitbee5cef7dbff40734c347da5b93797e8db9103e8 (patch)
tree06dcc726207cfad3016f2b0f7c365fb9fe5b3cc6 /Lib/distutils/dist.py
parentafb078dd2673d919ac3733104757c441f256f30f (diff)
downloadcpython-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.py8
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.