Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.0.X] Fixed #10014 -- Don't crash when using debug template tag ins…

…ide 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.

Backport of r9757 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9758 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 7cef4ecd19b83e6592a1afaedf6aff6fcb7b9e6e 1 parent ad93542
Malcolm Tredinnick authored January 16, 2009

Showing 1 changed file with 3 additions and 2 deletions. Show diff stats Hide diff stats

  1. 5  django/template/__init__.py
5  django/template/__init__.py
@@ -55,7 +55,7 @@
55 55
 from django.utils.itercompat import is_iterable
56 56
 from django.utils.functional import curry, Promise
57 57
 from django.utils.text import smart_split
58  
-from django.utils.encoding import smart_unicode, force_unicode
  58
+from django.utils.encoding import smart_unicode, force_unicode, smart_str
59 59
 from django.utils.translation import ugettext as _
60 60
 from django.utils.safestring import SafeData, EscapeData, mark_safe, mark_for_escaping
61 61
 from django.utils.html import escape
@@ -785,7 +785,8 @@ def __init__(self, s):
785 785
         self.s = s
786 786
 
787 787
     def __repr__(self):
788  
-        return "<Text Node: '%s'>" % self.s[:25]
  788
+        return "<Text Node: '%s'>" % smart_str(self.s[:25], 'ascii',
  789
+                errors='replace')
789 790
 
790 791
     def render(self, context):
791 792
         return self.s

0 notes on commit 7cef4ec

Please sign in to comment.
Something went wrong with that request. Please try again.