[PATCH 1 of 2] py3: convert to unicode to pass into encode()
Pulkit Goyal
7895pulkit at gmail.com
Fri Oct 7 10:04:23 EDT 2016
On Fri, Oct 7, 2016 at 3:42 PM, Yuya Nishihara <yuya at tcha.org> wrote:
> On Fri, 07 Oct 2016 14:05:41 +0200, Pulkit Goyal wrote:
>> # HG changeset patch
>> # User Pulkit Goyal <7895pulkit at gmail.com>
>> # Date 1475835208 -7200
>> # Fri Oct 07 12:13:28 2016 +0200
>> # Node ID 480cfc1623c2ad732300d942bbfab41343f7b8c5
>> # Parent 91a3c58ecf938ed675f5364b88f0d663f12b0047
>> py3: convert to unicode to pass into encode()
>>
>> encoding.encoding is bytes, we need to pass it to encode() which accepts
>> unicodes in py3, so used pycomapt.sysstr() Also this can't be done using
>> transformer as that only transforms the string values not variables.
>>
>> diff -r 91a3c58ecf93 -r 480cfc1623c2 mercurial/i18n.py
>> --- a/mercurial/i18n.py Mon Oct 03 13:24:56 2016 +0200
>> +++ b/mercurial/i18n.py Fri Oct 07 12:13:28 2016 +0200
>> @@ -12,7 +12,10 @@
>> import os
>> import sys
>>
>> -from . import encoding
>> +from . import (
>> + encoding,
>> + pycompat,
>> +)
>>
>> # modelled after templater.templatepath:
>> if getattr(sys, 'frozen', None) is not None:
>> @@ -85,6 +88,7 @@
>> # means u.encode(sys.getdefaultencoding()).decode(enc). Since
>> # the Python encoding defaults to 'ascii', this fails if the
>> # translated string use non-ASCII characters.
>> + encoding.encoding = pycompat.sysstr(encoding.encoding)
>
> We shouldn't convert encoding.encoding to unicode because it would break
> _('checking encoding (%s)...\n') % encoding.encoding, bytes % unicode, for
> example.
I am gonna change it to encodingstr =
pycompat.sysstr(encoding.encoding) and use encodingstr below. Drop the
patch as that was pushed.
>
>> _msgcache[message] = u.encode(encoding.encoding, "replace")
More information about the Mercurial-devel
mailing list