Fix file handle leak

This commit is contained in:
Éric Araujo 2011-05-01 02:05:58 +02:00
parent 46c09da3ca
commit 015014ff63

View file

@ -306,17 +306,20 @@ class sdist(Command):
rstrip_ws=1, rstrip_ws=1,
collapse_join=1) collapse_join=1)
while 1: try:
line = template.readline() while 1:
if line is None: # end of file line = template.readline()
break if line is None: # end of file
break
try: try:
self.filelist.process_template_line(line) self.filelist.process_template_line(line)
except DistutilsTemplateError, msg: except DistutilsTemplateError, msg:
self.warn("%s, line %d: %s" % (template.filename, self.warn("%s, line %d: %s" % (template.filename,
template.current_line, template.current_line,
msg)) msg))
finally:
template.close()
def prune_file_list(self): def prune_file_list(self):
"""Prune off branches that might slip into the file list as created """Prune off branches that might slip into the file list as created