I fixed another filehandle leak in the pdf backend, so here's a more
complete patch. There are also several cases of file(...) being passed
to pickle.dump or pickle.load in font_manager.py. I was going to take
care of these by writing some utility functions, but I started
wondering why the import of cPickle or pickle is done only within
methods of FontManager and not at the top level. Are there some
platforms where neither is available, or what is the rationale?

Index: backend_pdf.py
===================================================================
--- backend_pdf.py      (revision 3044)
+++ backend_pdf.py      (revision 3046)
@@ -457,7 +457,9 @@
         self.writeObject(self.fontObject, fonts)
     
     def _write_afm_font(self, filename):
-        font = AFM(file(filename))
+        fh = file(filename)
+        font = AFM(fh)
+        fh.close()
         fontname = font.get_fontname()
         fontdict = { 'Type': Name('Font'),
                      'Subtype': Name('Type1'),
@@ -1081,7 +1083,9 @@
         font = self.afm_font_cache.get(key)
         if font is None:
             filename = fontManager.findfont(prop, fontext='afm')
-            font = AFM(file(filename))
+            fh = file(filename)
+            font = AFM(fh)
+            fh.close()
             self.afm_font_cache[key] = font
         return font

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to