Patchwork [08,of,11,py3] ui: explicitly open config files in binary mode

login
register
mail settings
Submitter Augie Fackler
Date Oct. 9, 2016, 2:16 p.m.
Message ID <2f926a3f2409af24260f.1476022610@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/17005/
State Accepted
Headers show

Comments

Augie Fackler - Oct. 9, 2016, 2:16 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1476019069 14400
#      Sun Oct 09 09:17:49 2016 -0400
# Node ID 2f926a3f2409af24260f826ca1823c564ffea03e
# Parent  f2359d649c2164ba5efb3c202850064c7d777848
ui: explicitly open config files in binary mode

This has been working mostly accidentally, but now it works explicitly.
Yuya Nishihara - Oct. 10, 2016, 7:47 p.m.
On Sun, 09 Oct 2016 10:16:50 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1476019069 14400
> #      Sun Oct 09 09:17:49 2016 -0400
> # Node ID 2f926a3f2409af24260f826ca1823c564ffea03e
> # Parent  f2359d649c2164ba5efb3c202850064c7d777848
> ui: explicitly open config files in binary mode
> 
> This has been working mostly accidentally, but now it works explicitly.
> 
> diff --git a/mercurial/ui.py b/mercurial/ui.py
> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py
> @@ -176,7 +176,7 @@ class ui(object):
>      def readconfig(self, filename, root=None, trust=False,
>                     sections=None, remap=None):
>          try:
> -            fp = open(filename)
> +            fp = open(filename, u'rb')

Do we still need this after 1f01e3e33336 "py3: a second argument to open
can't be bytes" ?
Martijn Pieters - Oct. 11, 2016, 12:59 p.m.
On 10 October 2016 at 21:47, Yuya Nishihara <yuya@tcha.org> wrote:

> Do we still need this after 1f01e3e33336 "py3: a second argument to open
> can't be bytes" ?
>

I don't think so, no, but I haven't explicitly tested this line.
Augie Fackler - Oct. 11, 2016, 9:42 p.m.
> On Oct 11, 2016, at 8:59 AM, Martijn Pieters <mj@zopatista.com> wrote:
> 
> 
> On 10 October 2016 at 21:47, Yuya Nishihara <yuya@tcha.org> wrote:
> Do we still need this after 1f01e3e33336 "py3: a second argument to open
> can't be bytes" ?
> 
> I don't think so, no, but I haven't explicitly tested this line.

No, this patch isn’t needed anymore.

> 
> --
> Martijn Pieters

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -176,7 +176,7 @@  class ui(object):
     def readconfig(self, filename, root=None, trust=False,
                    sections=None, remap=None):
         try:
-            fp = open(filename)
+            fp = open(filename, u'rb')
         except IOError:
             if not sections: # ignore unless we were looking for something
                 return