[PATCH 5 of 5] check-code: handle py3 open divergence

Gregory Szorc gregory.szorc at gmail.com
Mon May 16 11:56:45 EDT 2016



> On May 16, 2016, at 06:06, Yuya Nishihara <yuya at tcha.org> wrote:
> 
>> On Sun, 15 May 2016 07:33:26 -0700, timeless wrote:
>> I don't know. I'm trying to take baby steps. If I or someone else hit a
>> problem with only ASCII, we can address it then.
> 
> It doesn't matter if encoding is 'ascii' or not. This patch implies we choose
> unicode over bytes for check-code.py, on Python 3. I think that would work
> for small scripts, but it scared me a little since we will do differently for
> the core modules.
> 
>>>> +    def opentext(f):
>>>> +        return open(f, encoding='ascii')
> 
> If we want to stick to bytes, it should be open(f, 'rb').

Python 3 treats source files as utf-8 by default. We should probably do the same. As long as the decoder is in strict mode, ascii should be OK for the immediate future.


More information about the Mercurial-devel mailing list