diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -156,7 +156,7 @@
                 def workerfunc():
                     os.close(rfd)
                     for i, item in func(*(staticargs + (pargs,))):
-                        os.write(wfd, '%d %s\n' % (i, item))
+                        os.write(wfd, '%d %s\n' % (i, pycompat.bytestr(item)))
                     return 0
 
                 ret = scmutil.callcatch(ui, workerfunc)