Commits

Anonymous committed 3726656

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

Comments (0)

Files changed (1)

     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')