Ticket #3509: smart_unicode_fix.patch
File smart_unicode_fix.patch, 975 bytes (added by , 18 years ago) |
---|
-
django/newforms/util.py
6 6 flatatt = lambda attrs: u''.join([u' %s="%s"' % (k, escape(v)) for k, v in attrs.items()]) 7 7 8 8 def 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) 16 17 return s 17 18 18 19 class StrAndUnicode(object):