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

Augie Fackler raf at durin42.com
Tue Oct 11 15:58:54 UTC 2016


> On Oct 11, 2016, at 11:20 AM, Yuya Nishihara <yuya at tcha.org> wrote:
> 
> 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.

I’ll have to find the link later, but on Sunday what I found was some documentation that the args were decoded using fsdecode.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20161011/29dbef71/attachment.asc>


More information about the Mercurial-devel mailing list