Can you try applying the attached patch and let me know if it resolves the problem for you?

Mike

On 12/17/2010 04:22 AM, Dieter Weber wrote:
Hi Mike,
sorry, I forgot my platform in my last mail!

I am running Ubuntu 10.04.1 LTS x86_64

Python: 2.6.5, Ubuntu
matplotlib: svn trunk, revision 8841

All other dependencies of matplotlib are installed as "normal" packages
of the distribution. Versions can be found here:
http://packages.ubuntu.com/lucid/python/

Would you like more information or should I run more tests?

Greetings,
Dieter

Am Donnerstag, den 16.12.2010, 15:40 -0500 schrieb Michael Droettboom:
What platform are you on?  It "works for me" on Fedora 14, RHEL 5 and
Cygwin.

Mike

On 12/16/2010 10:59 AM, Dieter Weber wrote:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import matplotlib
import matplotlib.pyplot as pp
import tempfile
import cStringIO as StringIO

matplotlib.rcParams['svg.embed_char_paths'] = False

pp.plot([1, 2], [1, 2], label=u"äöü")
pp.legend()

# works
pp.savefig('test.svg')

# breaks
with open('test2.svg', 'wb') as ofile:
      pp.savefig(ofile, format='svg')

# breaks
ostr = StringIO.StringIO()
pp.savefig(ostr, format='svg')


Index: lib/matplotlib/backends/backend_svg.py
===================================================================
--- lib/matplotlib/backends/backend_svg.py	(revision 8841)
+++ lib/matplotlib/backends/backend_svg.py	(working copy)
@@ -860,7 +860,7 @@
         if is_string_like(filename):
             fh_to_close = svgwriter = codecs.open(filename, 'w', 'utf-8')
         elif is_writable_file_like(filename):
-            svgwriter = codecs.EncodedFile(filename, 'utf-8')
+            svgwriter = codecs.getwriter('utf-8')(filename)
             fh_to_close = None
         else:
             raise ValueError("filename must be a path or a file-like object")
@@ -869,10 +869,10 @@
     def print_svgz(self, filename, *args, **kwargs):
         if is_string_like(filename):
             gzipwriter = gzip.GzipFile(filename, 'w')
-            fh_to_close = svgwriter = codecs.EncodedFile(gzipwriter, 'utf-8')
+            fh_to_close = svgwriter = codecs.getwriter('utf-8')(gzipwriter)
         elif is_writable_file_like(filename):
             fh_to_close = gzipwriter = gzip.GzipFile(fileobj=filename, mode='w')
-            svgwriter = codecs.EncodedFile(gzipwriter, 'utf-8')
+            svgwriter = codecs.getwriter('utf-8')(gzipwriter)
         else:
             raise ValueError("filename must be a path or a file-like object")
         return self._print_svg(filename, svgwriter, fh_to_close)
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to