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

Yuya Nishihara yuya at tcha.org
Sun May 15 06:42:44 EDT 2016


On Wed, 11 May 2016 04:12:50 +0000, timeless wrote:
> # HG changeset patch
> # User timeless <timeless at mozdev.org>
> # Date 1462931171 0
> #      Wed May 11 01:46:11 2016 +0000
> # Node ID c5dfd864d81f5d1f435ff376ea44b3ea82b12575
> # Parent  ed2dbfec165a0de79c93d7fa1ea9cb5f36b10c29
> # EXP-Topic runtests
> # Available At bb://timeless/mercurial-crew
> #              hg pull bb://timeless/mercurial-crew -r c5dfd864d81f
> check-code: handle py3 open divergence
> 
> open() really wants an encoding attribute
> 
> diff -r ed2dbfec165a -r c5dfd864d81f contrib/check-code.py
> --- a/contrib/check-code.py	Wed May 11 01:44:39 2016 +0000
> +++ b/contrib/check-code.py	Wed May 11 01:46:11 2016 +0000
> @@ -26,6 +26,11 @@
>  import os
>  import re
>  import sys
> +if sys.version_info[0] < 3:
> +    opentext = open
> +else:
> +    def opentext(f):
> +        return open(f, encoding='ascii')

Do we want a unicode on Python3 ?

I'm not saying we shouldn't, I just wondered. That would be manageable to
use unicodes in small scripts like check-code.py.


More information about the Mercurial-devel mailing list