Patchwork [1,of,6,py3] config: load included config files in binary mode

login
register
mail settings
Submitter Augie Fackler
Date March 3, 2017, 7:30 p.m.
Message ID <2a02a4ec5147f8bd6685.1488569404@imladris.local>
Download mbox | patch
Permalink /patch/18894/
State Accepted
Headers show

Comments

Augie Fackler - March 3, 2017, 7:30 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1488565704 18000
#      Fri Mar 03 13:28:24 2017 -0500
# Node ID 2a02a4ec5147f8bd6685a609ce9499b1266cc6db
# Parent  b4cd912d7704cd976e1bee3a3c927e0e578ec88f
config: load included config files in binary mode

I guess we've been getting lucky that this works in Python 2. This
fixes loading included config files in Python 3 (it used to fail on
the "somebody set up us the BOM" check.)

Patch

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')
         self.parse(path, fp.read(), sections, remap, self.read)