[PATCH] py3: have an utility function to return string

Pulkit Goyal 7895pulkit at gmail.com
Thu Sep 15 14:31:08 EDT 2016


On Thu, Sep 15, 2016 at 7:07 PM, Christian Ebert <blacktrash at gmx.net> wrote:
> * Pulkit Goyal on Wednesday, September 14, 2016 at 22:45:27 +0530
>> # HG changeset patch
>> # User Pulkit Goyal <7895pulkit at gmail.com>
>> # Date 1473787789 -19800
>> #      Tue Sep 13 22:59:49 2016 +0530
>> # Node ID ec133d50af780e84a6a24825b52d433c10f9cd55
>> # Parent  85bd31515225e7fdf9bd88edde054db2c74a33f8
>> py3: have an utility function to return string
>>
>> There are cases when we need strings and can't use bytes in python 3.
>> We need an utility function for these cases. I agree that this may not
>> be the best possible way out. I will be happy if anybody else can suggest
>> a better approach. We need this functions for os.path.join(), __slots__
>> and few more things. Added the function in pycompat.py as it is not too big
>> to import.
>>
>> diff -r 85bd31515225 -r ec133d50af78 mercurial/pycompat.py
>> --- a/mercurial/pycompat.py   Sun Aug 21 13:16:21 2016 +0900
>> +++ b/mercurial/pycompat.py   Tue Sep 13 22:59:49 2016 +0530
>> @@ -164,3 +164,18 @@
>>         "SimpleHTTPRequestHandler",
>>         "CGIHTTPRequestHandler",
>>     ))
>> +
>> +# This function converts its arguments to strings
>> +# on the basis of python version. Strings in python 3
>> +# are unicodes and our transformer converts everything to bytes
>> +# in python 3. So we need to decode it to unicodes in
>> +# py3.
>> +
>> +def coverttostr(word):
>
> converttostr I presume?

Yeah a typo by mistake, it should be converttostr


More information about the Mercurial-devel mailing list