[PATCH 09 of 11 py3] config: open config files as binary explicitly all the time

Yuya Nishihara yuya at tcha.org
Wed Nov 9 12:36:54 UTC 2016


On Sun, 09 Oct 2016 10:16:51 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie at google.com>
> # Date 1476019794 14400
> #      Sun Oct 09 09:29:54 2016 -0400
> # Node ID f3b993e256a8aeba26d2f927da9cf4428f7f1585
> # Parent  2f926a3f2409af24260f826ca1823c564ffea03e
> config: open config files as binary explicitly all the time
> 
> We had been getting lucky that on posix-like systems the default for
> files in Python 2 is binary IO, but now we're explicitly using binary
> IO all the time.
> 
> diff --git a/mercurial/config.py b/mercurial/config.py
> --- a/mercurial/config.py
> +++ b/mercurial/config.py
> @@ -169,5 +169,5 @@ class config(object):
>  
>      def read(self, path, fp=None, sections=None, remap=None):
>          if not fp:
> -            fp = util.posixfile(path)
> +            fp = util.posixfile(path, r'rb')

posixfile() isn't aliased to open() on Windows, and windows.posixfile() would
take bytes instead. Maybe we'll need pycompat.open() ?


More information about the Mercurial-devel mailing list