yosisa / TracBlockdiag

Integrate blockdiag series into Trac wiki
MIT License
6 stars 5 forks source link

SVG format fails with internal error: Can't send unicode content #1

Open ilewismsl opened 10 years ago

ilewismsl commented 10 years ago

Using Trac 1.0, TracBlockdiag 0.2.1, BlockDiag 1.3.2, Python 2.6.6.

When returning SVG result get the following from Trac: Trac detected an internal error: ValueError: Can't send unicode content

PNG works fine.

Source used: {{{#!blockdiag(type=svg) { A -> B -> C; } }}}

System Information
Package Version Trac 1 Docutils 0.11 Genshi 0.6 (without speedups) mod_python 3.3.1 Pygments 1.4 pysqlite 2.4.1 Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] setuptools 1.4.1 SQLite 3.5.9 Subversion 1.7.1 (r1186859) jQuery 1.7.2

enkore commented 10 years ago

The fix for this is really simple

diff --git a/tracblockdiag/diag.py b/tracblockdiag/diag.py
index f8cb29a..ab8781a 100644
--- a/tracblockdiag/diag.py
+++ b/tracblockdiag/diag.py
@@ -56,7 +56,7 @@ class BaseBuilder(object):
     def draw_svg(self, diagram, options):
         drawer = self.DiagramDraw('SVG', diagram, None, **options)
         drawer.draw()
-        return drawer.save()
+        return drawer.save().encode('utf-8')

     def create_fontmap(self, font):
         fontmap = FontMap()
bobatsar commented 9 years ago

thanks, that is what I needed too. Can't this patch be applied to the git repository?