Opened 16 years ago
Closed 12 years ago
#6904 closed defect (fixed)
Genshi UnicodeDecodeError error while rendering template (unknown template location)
| Reported by: | thuffir | Owned by: | Ryan J Ollos |
|---|---|---|---|
| Priority: | highest | Component: | TicketChartsMacro |
| Severity: | blocker | Keywords: | |
| Cc: | Ivanelson Nunes | Trac Release: | 0.12 |
Description (last modified by )
I have managed to install the plugin, but every time I try to call the macro I get the following error:
Trac Error Genshi UnicodeDecodeError error while rendering template (unknown template location)
Any Idea?
Attachments (0)
Change History (20)
comment:1 Changed 15 years ago by
| Severity: | normal → blocker |
|---|
comment:2 Changed 15 years ago by
| Priority: | normal → highest |
|---|
comment:3 Changed 12 years ago by
| Owner: | changed from aviram to Ryan J Ollos |
|---|---|
| Status: | new → assigned |
comment:4 Changed 12 years ago by
| Description: | modified (diff) |
|---|
comment:6 Changed 12 years ago by
| Trac Release: | 0.11 → 0.12 |
|---|
i am also getting same error while adding macro template to wiki page. please let me know if any fix on this.
comment:8 follow-up: 10 Changed 12 years ago by
comment:9 Changed 12 years ago by
| Cc: | Ivanelson Nunes added; anonymous removed |
|---|
ivanelson: Have you experienced this error?
comment:10 Changed 12 years ago by
Replying to rjollos:
(In [13247]) Refs #6904: Don't cast as a string, which can cause UnicodeDecode errors.
I think that it would be simple to use to_unicode and to_json (untested). Also to_js_string is available since Trac 0.12.4.
-
ticketcharts/TicketCharts.py
18 18 from trac.web.chrome import ITemplateProvider 19 19 from trac.wiki.macros import WikiMacroBase 20 20 from trac.ticket.query import Query 21 from trac.util.presentation import to_json 22 from trac.util.text import to_unicode 21 23 22 24 import openFlashChart 23 25 from openFlashChart_varieties import ( … … 185 187 return list(set(iterable)) 186 188 187 189 188 def _create_javascript_array(array_name, values, 189 function=lambda x: x and unicode(x) or ''): 190 from trac.util.text import to_js_string 191 array_values = ', '.join([to_js_string(function(value)) 192 for value in values]) 193 return 'var %s = new Array(%s)' % (array_name, array_values) 190 def _create_javascript_array(array_name, values, function=to_unicode): 191 return 'var %s = %s' % (array_name, to_json(map(function, values))) 194 192 195 193 196 194 def _create_query_object(env, query, required_columns=None):
comment:11 Changed 12 years ago by
Thanks, I'll test it out. I'm not proficient with unicode or the trac.util.text module, so the hints are appreciated.
comment:12 Changed 12 years ago by
comment:13 Changed 12 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
comment:14 follow-up: 15 Changed 12 years ago by
This bug is still reproducible for me.
I tracked it down to _get_random_string, whereas a non-utf8 string is generated. I am not sure why this happens, but my quick-and-dirty fix is to change _get_random_string in TicketCharts.py like that:
def _get_random_string(length):
#return ''.join([random.choice(string.letters + string.digits)
# for i in xrange(length)])
return str(random.randrange(111111111, 999999999))
comment:15 Changed 12 years ago by
Replying to lbolla@…:
I tracked it down to _get_random_string, whereas a non-utf8 string is generated. I am not sure why this happens, but my quick-and-dirty fix is to change
_get_random_stringinTicketCharts.pylike that:
Good catch! The behavior is caused that string.letters is locale-dependent.
>>> locale.setlocale(locale.LC_ALL, 'de_DE') 'de_DE' >>> string.letters 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\xaa\xb5\xba\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff'
I would like to use trac.util.hex_entropy instead of _get_random_string. I'll fix it shortly.
comment:17 follow-up: 18 Changed 12 years ago by
| Resolution: | fixed |
|---|---|
| Status: | closed → reopened |
Still i am getting the same error while adding macro template to wiki page.
Trac Error
Genshi UnicodeDecodeError error while rendering template (unknown template location)
Please let me whether it is fixed or any other solution?
Thanks sesha
comment:18 Changed 12 years ago by
| Resolution: | fixed |
|---|---|
| Status: | closed → reopened |
Replying to anonymous:
Still i am getting the same error while adding macro template to wiki page.
Could you please provide the details to reproduce it? e.g. trac.log, system information, the parameters for the macro, etc....
comment:19 Changed 12 years ago by
Any idea why both comment:17 and comment:18 show ticket resolution and status change?
comment:20 Changed 12 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | reopened → closed |
Thanks it works FINE.



same here...since thuffir is waiting for 8 months! I guess theres no hope of a fix either.
2010-11-25 16:35:47,252 Trac[formatter] DEBUG: Executing Wiki macro TicketChart by provider <TicketCharts.TicketChart object at 0x0344E910> 2010-11-25 16:35:47,273 Trac[formatter] ERROR: Macro TicketChart(type = pie, factor = milestone) failed: Traceback (most recent call last): File "C:\Program Files\BitNami Trac Stack\trac\Lib\site-packages\Trac-0.11.6-py2.5.egg\trac\wiki\formatter.py", line 484, in _macro_formatter return macro.process(args, in_paragraph=True) File "C:\Program Files\BitNami Trac Stack\trac\Lib\site-packages\Trac-0.11.6-py2.5.egg\trac\wiki\formatter.py", line 180, in process text = self.processor(text) File "C:\Program Files\BitNami Trac Stack\trac\Lib\site-packages\Trac-0.11.6-py2.5.egg\trac\wiki\formatter.py", line 167, in _macro_processor text) File "c:\program files\bitnami trac stack\python\lib\site-packages\TicketCharts.py", line 460, in expand_macro return create_graph(formatter.req, formatter.env, args) File "c:\program files\bitnami trac stack\python\lib\site-packages\TicketCharts.py", line 404, in create_graph chart, chart_div_id, additional_html = chart_creation[args['type']](env, db, args) File "c:\program files\bitnami trac stack\python\lib\site-packages\TicketCharts.py", line 391, in pie_graph return _pie_graph(env, db, args['factor'], query = args.get('query'), title = args.get('title')) File "c:\program files\bitnami trac stack\python\lib\site-packages\TicketCharts.py", line 386, in _pie_graph on_click_html = _create_pie_graph_on_click_html(env, ticket_stats, factor, query, on_click_function_name) File "c:\program files\bitnami trac stack\python\lib\site-packages\TicketCharts.py", line 355, in _create_pie_graph_on_click_html 'array_name' : array_name, File "c:\program files\bitnami trac stack\python\lib\site-packages\TicketCharts.py", line 142, in _safe_evaluate return string.Template(string_object).safe_substitute(mapping, **kw) File "C:\PROGRA~1\BITNAM~1\apache2\bin\lib\string.py", line 203, in safe_substitute return self.pattern.sub(convert, self.template) UnicodeDecodeError: 'ascii' codec can't decode byte 0xdb in position 27: ordinal not in range(128) 2010-11-25 16:35:47,275 Trac[main] WARNING: HTTPInternalError: 500 Trac Error (Genshi UnicodeDecodeError error while rendering template (unknown template location))