diff --git a/hgext/logtoprocess.py b/hgext/logtoprocess.py
index ff8b2886c492b7bae2b539bd858df4658fc96a3f_aGdleHQvbG9ndG9wcm9jZXNzLnB5..fbac323eb6250395674653868f3e325feb2a53e4_aGdleHQvbG9ndG9wcm9jZXNzLnB5 100644
--- a/hgext/logtoprocess.py
+++ b/hgext/logtoprocess.py
@@ -73,7 +73,7 @@
                 # positional arguments are listed as MSG[N] keys in the
                 # environment
                 msgpairs = (
-                    ('MSG{0:d}'.format(i), str(m))
+                    ('MSG{0:d}'.format(i), m)
                     for i, m in enumerate(messages, 1))
                 # keyword arguments get prefixed with OPT_ and uppercased
                 optpairs = (
@@ -77,5 +77,5 @@
                     for i, m in enumerate(messages, 1))
                 # keyword arguments get prefixed with OPT_ and uppercased
                 optpairs = (
-                    ('OPT_{0}'.format(key.upper()), str(value))
+                    ('OPT_{0}'.format(key.upper()), value)
                     for key, value in opts.iteritems())
@@ -81,8 +81,8 @@
                     for key, value in opts.iteritems())
-                env = dict(itertools.chain(procutil.shellenviron().items(),
-                                           msgpairs, optpairs),
-                           EVENT=event, HGPID=str(os.getpid()))
-                procutil.runbgcommand(script, env, shell=True)
+                env = dict(itertools.chain(msgpairs, optpairs),
+                           EVENT=event, HGPID=os.getpid())
+                fullenv = procutil.shellenviron(env)
+                procutil.runbgcommand(script, fullenv, shell=True)
             return super(logtoprocessui, self).log(event, *msg, **opts)
 
     # Replace the class for this instance and all clones created from it: