Django

Code

Changeset 6266

Show
Ignore:
Timestamp:
09/15/07 00:50:45 (1 year ago)
Author:
mtredinnick
Message:

Fixed some Python 2.3 unicode conversion problems. Uncovered by the tests, but that was just a sign of a real bug (luckily!).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/newforms/util.py

    r6140 r6266  
    11from django.utils.html import escape 
    2 from django.utils.encoding import smart_unicode, StrAndUnicode 
     2from django.utils.encoding import smart_unicode, StrAndUnicode, force_unicode 
    33from django.utils.functional import Promise 
    44 
     
    2323    def as_ul(self): 
    2424        if not self: return u'' 
    25         return u'<ul class="errorlist">%s</ul>' % ''.join([u'<li>%s%s</li>' % (k, smart_unicode(v)) for k, v in self.items()]) 
     25        return u'<ul class="errorlist">%s</ul>' % ''.join([u'<li>%s%s</li>' % (k, force_unicode(v)) for k, v in self.items()]) 
    2626 
    2727    def as_text(self): 
    28         return u'\n'.join([u'* %s\n%s' % (k, u'\n'.join([u'  * %s' % smart_unicode(i) for i in v])) for k, v in self.items()]) 
     28        return u'\n'.join([u'* %s\n%s' % (k, u'\n'.join([u'  * %s' % force_unicode(i) for i in v])) for k, v in self.items()]) 
    2929 
    3030class ErrorList(list, StrAndUnicode): 
     
    3737    def as_ul(self): 
    3838        if not self: return u'' 
    39         return u'<ul class="errorlist">%s</ul>' % ''.join([u'<li>%s</li>' % smart_unicode(e) for e in self]) 
     39        return u'<ul class="errorlist">%s</ul>' % ''.join([u'<li>%s</li>' % force_unicode(e) for e in self]) 
    4040 
    4141    def as_text(self): 
    4242        if not self: return u'' 
    43         return u'\n'.join([u'* %s' % smart_unicode(e) for e in self]) 
     43        return u'\n'.join([u'* %s' % force_unicode(e) for e in self]) 
    4444 
    4545class ValidationError(Exception): 
     
    5959        # See http://www.python.org/doc/current/tut/node10.html#handling 
    6060        return repr(self.messages) 
     61