diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py --- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -128,7 +128,8 @@ """Any text. Replaces the special XML/XHTML characters "&", "<" and ">" with XML entities, and filters out NUL characters. """ - return cgi.escape(text.replace('\0', ''), True) + return pycompat.sysbytes( + cgi.escape(pycompat.sysstr(text.replace('\0', '')), True)) para_re = None space_re = None