Ticket #5884: django_template_debug_handle_unicode_error.diff

File django_template_debug_handle_unicode_error.diff, 1.1 KB (added by guettli, 7 years ago)
  • django/template/__init__.py

     
    128128        self.msg = msg
    129129        self.params = params
    130130
    131     def __str__(self):
    132         return self.msg % self.params
     131    def __unicode__(self):
     132        return self.msg % tuple([force_unicode(p, errors='replace') for p in self.params])
    133133
    134134class InvalidTemplateLibrary(Exception):
    135135    pass
  • django/template/debug.py

     
    7575            raise
    7676        except Exception, e:
    7777            from sys import exc_info
    78             wrapped = TemplateSyntaxError('Caught an exception while rendering: %s' % e)
     78            wrapped = TemplateSyntaxError(u'Caught an exception while rendering: %s' % force_unicode(e, errors='replace'))
    7979            wrapped.source = node.source
    8080            wrapped.exc_info = exc_info()
    8181            raise wrapped
Back to Top