Modify ↓
Opened 11 years ago
Closed 11 years ago
#11780 closed defect (fixed)
UnicodeError with its traceback should be logged while rendering genshi template
| Reported by: | Jun Omae | Owned by: | Jun Omae |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.0.5 |
| Component: | rendering | Version: | 0.12-stable |
| Severity: | normal | Keywords: | genshi |
| Cc: | Branch: | ||
| Release Notes: |
Add template name to error message if an exception is raised while rendering and location is unknown. |
||
| API Changes: | |||
| Internal Changes: | |||
Description
If an UnicodeError raises while rendering genshi template, traceback of the error will not be logged. The behavior makes increasingly difficult to solve, especially if rendering unknown template location.
I think we should log the error with its traceback in this case.
-
trac/web/chrome.py
diff --git a/trac/web/chrome.py b/trac/web/chrome.py index 344448b..fd14cbd 100644
a b class Chrome(Component): 885 885 req.chrome['script_data'] = script_data 886 886 # give some hints when hitting a Genshi unicode error 887 887 if isinstance(e, UnicodeError): 888 self.log.error('Exception caught while rendering %s%s', 889 filename, 890 exception_to_unicode(e, traceback=True)) 888 891 pos = self._stream_location(stream) 889 892 if pos: 890 893 location = "'%s', line %s, char %s" % pos
Attachments (0)
Change History (5)
comment:1 by , 11 years ago
| Milestone: | 0.12.7 → 1.0.3 |
|---|---|
| Owner: | set to |
| Status: | new → assigned |
comment:2 by , 11 years ago
| Milestone: | 1.0.3 → 1.0.4 |
|---|
comment:3 by , 11 years ago
| Milestone: | 1.0.4 → 1.0.5 |
|---|
comment:4 by , 11 years ago
comment:5 by , 11 years ago
| Release Notes: | modified (diff) |
|---|---|
| Resolution: | → fixed |
| Status: | assigned → closed |
Committed the patch in comment:4 in [13779-13780].
Note:
See TracTickets
for help on using tickets.



That is less-useful….
2015-02-21 18:15:16,332 Trac[chrome] ERROR: Genshi UnicodeDecodeError error while rendering template ticket.html Traceback (most recent call last): File "/src/tracdev/git/trac/web/chrome.py", line 1096, in render_template encoding='utf-8') File "/venv/py25-1.0/lib/python2.5/site-packages/genshi/core.py", line 184, in render ... File "/venv/py25-1.0/lib/python2.5/site-packages/genshi/template/eval.py", line 178, in evaluate File "/src/tracdev/git/trac/ticket/templates/ticket_box.html", line 124, in <Expression u'wiki_to_html(context, ticket.description, escape_newlines=preserve_newlines)'> ${wiki_to_html(context, ticket.description, escape_newlines=preserve_newlines)} File "/src/tracdev/git/trac/wiki/formatter.py", line 1579, in format_to_html return HtmlFormatter(env, context, wikidom).generate(escape_newlines) File "/src/tracdev/git/trac/wiki/formatter.py", line 1534, in generate escape_newlines) File "/src/tracdev/git/trac/wiki/formatter.py", line 1316, in format result = re.sub(self.wikiparser.rules, self.replace, line) File "/home/jun66j5/venv/py25-1.0/lib/python2.5/re.py", line 150, in sub return _compile(pattern, 0).sub(repl, string, count) File "/src/tracdev/git/trac/wiki/formatter.py", line 1236, in replace return _markup_to_unicode(replacement) File "/src/tracdev/git/trac/wiki/formatter.py", line 109, in _markup_to_unicode markup = stream.render('xhtml', encoding=None, strip_whitespace=False) File "/venv/py25-1.0/lib/python2.5/site-packages/genshi/core.py", line 184, in render File "/venv/py25-1.0/lib/python2.5/site-packages/genshi/output.py", line 57, in encode File "/venv/py25-1.0/lib/python2.5/site-packages/genshi/output.py", line 387, in __call__ UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 2999: ordinal not in range(128) 2015-02-21 18:15:16,332 Trac[main] WARNING: [192.168.11.13] HTTPInternalError: 500 Trac Error (Genshi UnicodeDecodeError error while rendering template (unknown template location))Instead, it would be better to add the template filename to error message when (unknown template location).
trac/web/chrome.py