﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
10014	debug template tag fails in utf-8 encoded template	ledermann@…	Malcolm Tredinnick	"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."		closed	Template system	1.0		fixed	unicode, utf-8, template		Unreviewed	0	0	0	0	0	0
