diff --git a/gluon/html.py b/gluon/html.py index da8e2d6e..ceef7bd2 100644 --- a/gluon/html.py +++ b/gluon/html.py @@ -20,7 +20,7 @@ import urllib import base64 from gluon import sanitizer, decoder import itertools -from gluon._compat import reduce, pickle, copyreg, HTMLParser, name2codepoint, iteritems, unichr, unicodeT, urllib_quote, to_bytes, to_native, to_unicode, basestring, urlencode, implements_bool +from gluon._compat import reduce, pickle, copyreg, HTMLParser, name2codepoint, iteritems, unichr, unicodeT, urllib_quote, to_bytes, to_native, to_unicode, basestring, urlencode, implements_bool, text_type from gluon.utils import local_html_escape import marshal @@ -122,7 +122,7 @@ def xmlescape(data, quote=True): if hasattr(data, 'xml') and callable(data.xml): return to_bytes(data.xml()) - if not(isinstance(data, basestring)): + if not(isinstance(data, (text_type, bytes))): # i.e., integers data=str(data) data = to_bytes(data, 'utf8', 'xmlcharrefreplace') @@ -1040,7 +1040,7 @@ class DIV(XmlComponent): hello >>> a.elements('a[u:v=$]')[0].xml() 'hello' - >>> a=FORM( INPUT(_type='text'), SELECT(range(1)), TEXTAREA() ) + >>> a=FORM( INPUT(_type='text'), SELECT(list(range(1))), TEXTAREA() ) >>> for c in a.elements('input, select, textarea'): c['_disabled'] = 'disabled' >>> a.xml() '
' diff --git a/gluon/tests/test_html.py b/gluon/tests/test_html.py index d7a75517..e091d1ce 100644 --- a/gluon/tests/test_html.py +++ b/gluon/tests/test_html.py @@ -253,6 +253,7 @@ class TestBareHelpers(unittest.TestCase): # test .get('attrib') self.assertEqual(DIV('

Test

', _class="class_test").get('_class'), 'class_test') + self.assertEqual(DIV(b'a').xml(), b'
a
') def test_CAT(self): # Empty CAT()