Ticket #3509: smart_unicode_fix.patch

File smart_unicode_fix.patch, 975 bytes (added by Anton Khalikov <anton@…>, 9 years ago)

Quick fix

  • django/newforms/util.py

     
    66flatatt = lambda attrs: u''.join([u' %s="%s"' % (k, escape(v)) for k, v in attrs.items()])
    77
    88def smart_unicode(s):
    9     if not isinstance(s, basestring):
    10         if hasattr(s, '__unicode__'):
    11             s = unicode(s)
    12         else:
    13             s = unicode(str(s), settings.DEFAULT_CHARSET)
    14     elif not isinstance(s, unicode):
    15         s = unicode(s, settings.DEFAULT_CHARSET)
     9    if not s in (None, True, False):
     10        if not isinstance(s, basestring):
     11            if hasattr(s, '__unicode__'):
     12                s = unicode(s)
     13            else:
     14                s = unicode(str(s), settings.DEFAULT_CHARSET)
     15        elif not isinstance(s, unicode):
     16            s = unicode(s, settings.DEFAULT_CHARSET)
    1617    return s
    1718
    1819class StrAndUnicode(object):
Back to Top