Modify

Opened 5 years ago

Last modified 5 years ago

#4760 new defect

Fix for Markup(map) with unicoded strings when using MasterTicketsPlugin depgraph

Reported by: shurup Owned by: cboos
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)

graphvizplugin-unicoded-map-depgraph.patch (592 bytes) - added by shurup 5 years ago.

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by shurup

comment:1 Changed 5 years ago by anonymous

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', '')

comment:2 Changed 5 years ago by anonymous

This GraphvizPlugin macro triggers an "Genshi UnicodeDecodeError error while rendering template"

Error: Failed to load processor graphviz
No macro or processor named 'graphviz' found

(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 5 years ago by anonymous

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 5 years ago by cboos

  • Keywords unicode added
  • Owner changed from pkropf to cboos
  • Priority changed from low to high
  • Severity changed from trivial to normal

Add Comment

Modify Ticket

Action
as new .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.