Permalink
Browse files

Fixed #5884 -- Added better display error handling for template vari…

…ables.

Combined work from Karen Tracey and Thomas Güttler.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7260 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
malcolmt committed Mar 17, 2008
1 parent 7320745 commit b5adaec4c23e3fa8ab52da1c10eb52f775d02209
Showing with 5 additions and 2 deletions.
  1. +4 −1 django/template/__init__.py
  2. +1 −1 django/template/debug.py
@@ -129,7 +129,10 @@ def __init__(self, msg, params=()):
self.params = params
def __str__(self):
- return self.msg % self.params
+ return unicode(self).encode('utf-8')
+
+ def __unicode__(self):
+ return self.msg % tuple([force_unicode(p, errors='replace') for p in self.params])
class InvalidTemplateLibrary(Exception):
pass
View
@@ -75,7 +75,7 @@ def render_node(self, node, context):
raise
except Exception, e:
from sys import exc_info
- wrapped = TemplateSyntaxError('Caught an exception while rendering: %s' % e)
+ wrapped = TemplateSyntaxError(u'Caught an exception while rendering: %s' % force_unicode(e, errors='replace'))
wrapped.source = node.source
wrapped.exc_info = exc_info()
raise wrapped

0 comments on commit b5adaec

Please sign in to comment.