Opened 17 years ago
Last modified 16 years ago
#4760 new defect
Fix for Markup(map) with unicoded strings when using MasterTicketsPlugin depgraph
| Reported by: | Dmitry Shurupov | Owned by: | Christian Boos |
|---|---|---|---|
| Priority: | high | Component: | GraphvizPlugin |
| Severity: | normal | Keywords: | unicode |
| Cc: | Trac Release: | 0.11 |
Description
I'm using MasterTicketsPlugin with GraphvizPlugin. And I have some cyrillic symbols in my tickets. When I was trying to create a depgraph for any ticket, I was getting this error:
Trac detected an internal error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 43: ordinal not in range(128)
That's the source of this problem:
File "build/bdist.linux-x86_64/egg/depgraph/web_ui.py", line 146, in process_requestFile "build/bdist.linux-x86_64/egg/depgraph/depgraph.py", line 240, in expand_macroFile "build/bdist.linux-x86_64/egg/graphviz/graphviz.py", line 406, in expand_macro
I don't know Python language, but I've figured how to fix it. I've changed the "open(map_path, 'r')" to "codecs.open(map_path, 'r', 'utf-8')" and added "import codecs". Now, this problem has gone, and everything seems to work.
Patch for graphvizplugin 0.11-0.7.4 is attached. Feel free to make something more reasonable than stupid code from non-python (non-)programmer.
Attachments (1)
Change History (5)
Changed 17 years ago by
| Attachment: | graphvizplugin-unicoded-map-depgraph.patch added |
|---|
comment:1 Changed 17 years ago by
comment:2 Changed 17 years ago by
This GraphvizPlugin macro triggers an "Genshi UnicodeDecodeError error while rendering template"
(replace UniformResourceLocator with its three-letter abbreviation, I tried this to get past the spam filter)
The above patch(es) fixes this issue.
comment:3 Changed 17 years ago by
Now, really! I forgot this would be interpreted as a macro call :-)
#!graphviz
digraph G {
Sundström [UniformResourceLocator=Sundström]
}
and again, replace UniformResourceLocator? with its three-letter abbreviation...
comment:4 Changed 16 years ago by
| Keywords: | unicode added |
|---|---|
| Owner: | changed from Peter Kropf to Christian Boos |
| Priority: | low → high |
| Severity: | trivial → normal |



Had the same problem, not involving the MasterTicketsPlugin, but was trying to generate a map file with URLs/labels with utf-8 characters. Did the exact same fix, here is the patch...
Index: 0.11/graphviz/graphviz.py =================================================================== --- 0.11/graphviz/graphviz.py (revision 5353) +++ 0.11/graphviz/graphviz.py (working copy) @@ -23,6 +23,7 @@ import sha import subprocess import sys +import codecs from genshi.builder import Element, tag from genshi.core import Markup @@ -402,7 +403,7 @@ # for binary formats, add map elif URL_in_graph and os.path.exists(map_path): - f = open(map_path, 'r') + f = codecs.open(map_path, 'r', 'utf-8') map = f.readlines() f.close() map = "".join(map).replace('\n', '')