From 14b3f03015081a679a6b5efaf5ea925344ce14c0 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Fri, 16 Jan 2009 08:59:02 +0000 Subject: [PATCH] Fixed #10014 -- Don't crash when using debug template tag inside a block node tag. Returning non-ASCII characters from TextNode.__repr__ was causing problems in the BlockNode.__repr__ method (and probably in other places we don't know about yet). We now forcibly convert to ascii and replace any unconvertible characters, rather than returning some moderately corrupted data in the non-ASCII case. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9757 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/template/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/django/template/__init__.py b/django/template/__init__.py index f84a1cef66..bdc4b890d1 100644 --- a/django/template/__init__.py +++ b/django/template/__init__.py @@ -55,7 +55,7 @@ from django.template.context import Context, RequestContext, ContextPopException from django.utils.itercompat import is_iterable from django.utils.functional import curry, Promise from django.utils.text import smart_split -from django.utils.encoding import smart_unicode, force_unicode +from django.utils.encoding import smart_unicode, force_unicode, smart_str from django.utils.translation import ugettext as _ from django.utils.safestring import SafeData, EscapeData, mark_safe, mark_for_escaping from django.utils.html import escape @@ -785,7 +785,8 @@ class TextNode(Node): self.s = s def __repr__(self): - return "" % self.s[:25] + return "" % smart_str(self.s[:25], 'ascii', + errors='replace') def render(self, context): return self.s