From: Éric Araujo Date: Sun, 17 Apr 2011 12:27:07 +0000 (+0200) Subject: Fix resource warning found manually X-Git-Tag: v3.2.1b1~71^2~4^2^2~1^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dcb22a39366f7bea8aa3359803ee32fe46debf58;p=thirdparty%2FPython%2Fcpython.git Fix resource warning found manually --- diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py index 1118060cbb98..fdbebd7e0fc4 100644 --- a/Lib/distutils/command/sdist.py +++ b/Lib/distutils/command/sdist.py @@ -294,17 +294,20 @@ class sdist(Command): join_lines=1, lstrip_ws=1, rstrip_ws=1, collapse_join=1) - while True: - line = template.readline() - if line is None: # end of file - break - - try: - self.filelist.process_template_line(line) - except DistutilsTemplateError as msg: - self.warn("%s, line %d: %s" % (template.filename, - template.current_line, - msg)) + try: + while True: + line = template.readline() + if line is None: # end of file + break + + try: + self.filelist.process_template_line(line) + except DistutilsTemplateError as msg: + self.warn("%s, line %d: %s" % (template.filename, + template.current_line, + msg)) + finally: + template.close() def prune_file_list(self): """Prune off branches that might slip into the file list as created