[PATCH 07 of 11 py3] dispatch: translate argv back to bytes on Python 3

Yuya Nishihara yuya at tcha.org
Tue Oct 11 11:20:04 EDT 2016


On Sun, 09 Oct 2016 10:16:49 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie at google.com>
> # Date 1476018603 14400
> #      Sun Oct 09 09:10:03 2016 -0400
> # Node ID f2359d649c2164ba5efb3c202850064c7d777848
> # Parent  88a5fecb60831eea7c44c6d6025ee23513528501
> dispatch: translate argv back to bytes on Python 3
> 
> diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
> --- a/mercurial/dispatch.py
> +++ b/mercurial/dispatch.py
> @@ -57,7 +57,11 @@ class request(object):
>  
>  def run():
>      "run the command in sys.argv"
> -    sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
> +    if sys.version_info > (3,4):
> +        argv = list(map(os.fsencode, sys.argv))
> +    else:
> +        argv = sys.argv

argv may contain arbitrary strings (e.g. commit message, branch, etc.)
unrelated to fsencode. So I think HGENCODING is the best guess here.


More information about the Mercurial-devel mailing list