Fix file handle leak

This commit is contained in:
Éric Araujo 2011-05-01 02:05:58 +02:00
parent 46c09da3ca
commit 015014ff63
1 changed files with 13 additions and 10 deletions

View File

@ -306,17 +306,20 @@ class sdist(Command):
rstrip_ws=1,
collapse_join=1)
while 1:
line = template.readline()
if line is None: # end of file
break
try:
while 1:
line = template.readline()
if line is None: # end of file
break
try:
self.filelist.process_template_line(line)
except DistutilsTemplateError, msg:
self.warn("%s, line %d: %s" % (template.filename,
template.current_line,
msg))
try:
self.filelist.process_template_line(line)
except DistutilsTemplateError, 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