summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-05-01 02:05:58 +0200
committerÉric Araujo <merwok@netwok.org>2011-05-01 02:05:58 +0200
commit9e39e53a36843c1d603a54bf4e517411a2023a5c (patch)
tree9145869b59e8d29d713094b8374d982b076ccfb5 /Lib
parent130e37365eb36a21ebd8c52ad8a69f045a61364f (diff)
downloadcpython-9e39e53a36843c1d603a54bf4e517411a2023a5c.tar.gz
Fix file handle leak
Diffstat (limited to 'Lib')
-rw-r--r--Lib/distutils/command/sdist.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
index 0c3b0b55bf..cf8982bd9d 100644
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -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:
- self.filelist.process_template_line(line)
- except DistutilsTemplateError, msg:
- self.warn("%s, line %d: %s" % (template.filename,
- template.current_line,
- msg))
+ 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))
+ finally:
+ template.close()
def prune_file_list(self):
"""Prune off branches that might slip into the file list as created