diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -1130,10 +1130,10 @@ class ui(object): try: pager = subprocess.Popen( - command, shell=shell, bufsize=-1, + procutil.tonativestr(command), shell=shell, bufsize=-1, close_fds=procutil.closefds, stdin=subprocess.PIPE, stdout=procutil.stdout, stderr=procutil.stderr, - env=procutil.shellenviron(env)) + env=procutil.tonativeenv(procutil.shellenviron(env))) except OSError as e: if e.errno == errno.ENOENT and not shell: self.warn(_("missing pager command '%s', skipping pager\n") diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py --- a/mercurial/utils/procutil.py +++ b/mercurial/utils/procutil.py @@ -320,10 +320,19 @@ def shellenviron(environ=None): if pycompat.iswindows: def shelltonative(cmd, env): return platform.shelltocmdexe(cmd, shellenviron(env)) + + tonativestr = encoding.strfromlocal else: def shelltonative(cmd, env): return cmd + tonativestr = pycompat.identity + +def tonativeenv(env): + '''convert the environment from bytes to strings suitable for Popen(), etc. + ''' + return pycompat.rapply(tonativestr, env) + def system(cmd, environ=None, cwd=None, out=None): '''enhanced shell command execution. run with environment maybe modified, maybe in different dir.