#10014: debug template tag fails in utf-8 encoded template
----------------------------------------+-----------------------------------
Reporter: [email protected] | Owner: nobody
Status: new | Milestone:
Component: Template system | Version: 1.0
Keywords: unicode, utf-8, template | Stage: Unreviewed
Has_patch: 0 |
----------------------------------------+-----------------------------------
Using the {% debug %} template tag inside a UTF-8 encoded template file
that contains non-ASCII characters fails with an encoding error.
Interestingly, this occurs only if the debug tag is used within a block.
I have attached a minimal test case. If you save that file as UTF-8 and
render the template with render_to_response('test.html'), you should be
able to see the bug.
Removing the 'รค' character from the template /or/ moving the {% debug %}
tag outside the block makes the bug disappear.
Stack trace of the bug:
{{{
Caught an exception while rendering: 'ascii' codec can't encode character
u'\xe4' in position 14: ordinal not in range(128)
Original Traceback (most recent call last):
File "C:\lib\Python2.5.2\lib\site-packages\django\template\debug.py",
line 71, in render_node
result = node.render(context)
File "C:\lib\Python2.5.2\lib\site-
packages\django\template\defaulttags.py", line 54, in render
output = [pformat(val) for val in context]
File "C:\lib\Python2.5.2\lib\pprint.py", line 59, in pformat
return PrettyPrinter(indent=indent, width=width,
depth=depth).pformat(object)
File "C:\lib\Python2.5.2\lib\pprint.py", line 111, in pformat
self._format(object, sio, 0, 0, {}, 0)
File "C:\lib\Python2.5.2\lib\pprint.py", line 129, in _format
rep = self._repr(object, context, level - 1)
File "C:\lib\Python2.5.2\lib\pprint.py", line 195, in _repr
self._depth, level)
File "C:\lib\Python2.5.2\lib\pprint.py", line 207, in format
return _safe_repr(object, context, maxlevels, level)
File "C:\lib\Python2.5.2\lib\pprint.py", line 251, in _safe_repr
vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level)
File "C:\lib\Python2.5.2\lib\pprint.py", line 292, in _safe_repr
rep = repr(object)
File "C:\lib\Python2.5.2\lib\site-
packages\django\template\loader_tags.py", line 17, in __repr__
return "<Block Node: %s. Contents: %r>" % (self.name, self.nodelist)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in
position 14: ordinal not in range(128)
}}}
I am using Django 1.0 final.
--
Ticket URL: <http://code.djangoproject.com/ticket/10014>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---