devtools/testlib.py
changeset 10689 49a62b8f6d43
parent 10687 d394bfcd8c25
child 10700 a6d9d27f4253
--- a/devtools/testlib.py	Wed Sep 16 13:57:21 2015 +0200
+++ b/devtools/testlib.py	Wed Sep 16 15:17:42 2015 +0200
@@ -961,11 +961,11 @@
         if content_type is None:
             content_type = 'text/html'
         if content_type in ('text/html', 'application/xhtml+xml') and output:
-            if output.startswith('<!DOCTYPE html>'):
+            if output.startswith(b'<!DOCTYPE html>'):
                 # only check XML well-formness since HTMLValidator isn't html5
                 # compatible and won't like various other extensions
                 default_validator = htmlparser.XMLSyntaxValidator
-            elif output.startswith('<?xml'):
+            elif output.startswith(b'<?xml'):
                 default_validator = htmlparser.DTDValidator
             else:
                 default_validator = htmlparser.HTMLValidator
@@ -1006,7 +1006,7 @@
                 str_exc = str(exc)
             except Exception:
                 str_exc = 'undisplayable exception'
-            msg += str_exc
+            msg += str_exc.encode(sys.getdefaultencoding(), 'replace')
             if content is not None:
                 position = getattr(exc, "position", (0,))[0]
                 if position: