diff --git a/hgext/highlight/__init__.py b/hgext/highlight/__init__.py
--- a/hgext/highlight/__init__.py
+++ b/hgext/highlight/__init__.py
@@ -105,4 +105,4 @@ def extsetup(ui):
     )
     extensions.wrapfunction(webcommands, 'annotate', annotate_highlight)
     webcommands.highlightcss = generate_css
-    webcommands.__all__.append(b'highlightcss')
+    webcommands.__all__.append('highlightcss')
diff --git a/hgext/zeroconf/Zeroconf.py b/hgext/zeroconf/Zeroconf.py
--- a/hgext/zeroconf/Zeroconf.py
+++ b/hgext/zeroconf/Zeroconf.py
@@ -89,7 +89,7 @@ import traceback
 
 from mercurial import pycompat
 
-__all__ = [b"Zeroconf", b"ServiceInfo", b"ServiceBrowser"]
+__all__ = ["Zeroconf", "ServiceInfo", "ServiceBrowser"]
 
 # hook for threads
 
diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -464,7 +464,7 @@ class hgweb:
 
                 res.headers[b'ETag'] = tag
 
-            if cmd not in webcommands.__all__:
+            if pycompat.sysstr(cmd) not in webcommands.__all__:
                 msg = b'no such method: %s' % cmd
                 raise ErrorResponse(HTTP_BAD_REQUEST, msg)
             else:
diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -72,7 +72,7 @@ class webcommand:
         self.name = name
 
     def __call__(self, func):
-        __all__.append(self.name)
+        __all__.append(pycompat.sysstr(self.name))
         commands[self.name] = func
         return func
 
diff --git a/mercurial/lsprof.py b/mercurial/lsprof.py
--- a/mercurial/lsprof.py
+++ b/mercurial/lsprof.py
@@ -6,7 +6,7 @@ Profiler = _lsprof.Profiler
 # PyPy doesn't expose profiler_entry from the module.
 profiler_entry = getattr(_lsprof, 'profiler_entry', None)
 
-__all__ = [b'profile', b'Stats']
+__all__ = ['profile', 'Stats']
 
 
 def profile(f, *args, **kwds):
diff --git a/mercurial/statprof.py b/mercurial/statprof.py
--- a/mercurial/statprof.py
+++ b/mercurial/statprof.py
@@ -122,7 +122,7 @@ from . import (
 defaultdict = collections.defaultdict
 contextmanager = contextlib.contextmanager
 
-__all__ = [b'start', b'stop', b'reset', b'display', b'profile']
+__all__ = ['start', 'stop', 'reset', 'display', 'profile']
 
 skips = {
     "util.py:check",
diff --git a/tests/hgweberror.py b/tests/hgweberror.py
--- a/tests/hgweberror.py
+++ b/tests/hgweberror.py
@@ -20,4 +20,4 @@ def raiseerror(web):
 
 def extsetup(ui):
     setattr(webcommands, 'raiseerror', raiseerror)
-    webcommands.__all__.append(b'raiseerror')
+    webcommands.__all__.append('raiseerror')