From 623fc895d7dd7e0ce036699bc7e3be3421b81645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sat, 6 Nov 2010 02:58:56 +0000 Subject: 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 ........ --- Lib/distutils/dist.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Lib/distutils/dist.py') diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py index 1c1ea477db..01f1f1cfc0 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. -- cgit v1.2.1