]> granicus.if.org Git - python/commitdiff
Fix resource warning found manually
authorÉric Araujo <merwok@netwok.org>
Sun, 17 Apr 2011 12:27:07 +0000 (14:27 +0200)
committerÉric Araujo <merwok@netwok.org>
Sun, 17 Apr 2011 12:27:07 +0000 (14:27 +0200)
Lib/distutils/command/sdist.py

index 1118060cbb98bfa1499cdd7696485f4276327f31..fdbebd7e0fc451accbe58bf28be1f958dea7a5f5 100644 (file)
@@ -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