avoid open file handler leak 3.5
authorAurelien Campeas
Wed, 09 Sep 2009 17:45:34 +0200
branch3.5
changeset 3145 9b28545de60d
parent 3139 c527984d6651
child 3146 cfc4344023f2
avoid open file handler leak
web/views/__init__.py
--- a/web/views/__init__.py	Wed Sep 09 15:12:42 2009 +0200
+++ b/web/views/__init__.py	Wed Sep 09 17:45:34 2009 +0200
@@ -111,13 +111,8 @@
 
     def cell_call(self, row=0, col=0):
         self.row, self.col = row, col # in case one needs it
-        _, tmpfile = tempfile.mkstemp('.png')
-        try:
-            self._generate(tmpfile)
-            self.w(open(tmpfile, 'rb').read())
-        finally:
-            try:
-                os.unlink(tmpfile)
-            except Exception, ex:
-                if sys.platform != 'win32':
-                      self.warning("can't delete %s : %s" % (tmpfile, ex))
+        fd, tmpfile = tempfile.mkstemp('.png')
+        os.close(fd)
+        self._generate(tmpfile)
+        self.w(open(tmpfile, 'rb').read())
+        os.unlink(tmpfile)