Commits

Anonymous committed 50d1e9c

[svn] Added special-casing of None

Comments (0)

Files changed (2)

tests/test_escapes.py

             return u'<\u1000>'
     assert html_escape(X()) == '&lt;&#4096;&gt;'
     assert html_escape(1) == '1'
+    assert html_escape(None) == ''

webhelpers/escapes.py

     (actually, using ``unicode()``).  All values returned are
     non-unicode strings (using ``&#num;`` entities for all non-ASCII
     characters).
+
+    None is treated specially, and returns the empty string.
     """
+    if s is None:
+        return ''
     if not isinstance(s, basestring):
         s = unicode(s)
     s = cgi.escape(s, True)