Commits

ianb  committed 3726656

[svn] in html_escape, don't convert something to unicode if it doesn't implement __unicode__

  • Participants
  • Parent commits 37fbc9c

Comments (0)

Files changed (1)

File webhelpers/util.py

     if s is None:
         return ''
     if not isinstance(s, basestring):
-        s = unicode(s)
+        if hasattr(s, '__unicode__'):
+            s = unicode(s)
+        else:
+            s = str(s)
     s = cgi.escape(s, True)
     if isinstance(s, unicode):
         s = s.encode('ascii', 'xmlcharrefreplace')