showworkflow script can't handle accented characters in workflow states
|Reported by:||Owned by:||Eli Carter|
Description (last modified by )
trac seems to be able to handle accented characters in state names or transition names. The showworkflow script, however, fails with the following exception when run on a .ini file that trac can handle:
Traceback (most recent call last): File "./workflow_parser.py", line 109, in ? main(args, show_ops, show_perms) File "./workflow_parser.py", line 76, in main sys.stdout.write(''.join(digraph_lines)) UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 189: ordinal not in range(128) Failed to parse "inventory-workflow.ini", exiting.
The bug is actually in workflow_parser.py (and python's handling of sys.stdout): showworkflow runs workflow_parser.py and redirects the output. Because sys.stdout is redirected, its encoding is set to None, which means that ascii encoding is used. This can't handle most accented characters, result in the exception.
A possible fix is to set encoding of sys.stdout in workflow_parser.py, by replacing
import locale, codecs sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout); sys.stdout.write(''.join(digraph_lines))
After this, showworkflow script will run and produce correct .png output. .ps output, however, will be wrong as graphviz doesn't appear to be able to handle non- latin-1 chars in ps output (see "More generally, how do I use non-ASCII character sets?" in http://www.graphviz.org/doc/FAQ.html)
.pdf output, however appears to work, so I think instead of using ps2pdf, .pdf should be seperatelly generated with
dot -T pdf -o ...filenames...
Change History (9)
comment:3 Changed 10 years ago by
|Component:||general → ticket system|
comment:4 Changed 10 years ago by
|Milestone:||0.11.2 → 0.11.3|
|Severity:||normal → minor|