Patchwork [09,of,11] changelog: fix default open mode to use bytes io instead of str

login
register
mail settings
Submitter Augie Fackler
Date March 26, 2017, 10:36 p.m.
Message ID <386820bf1ae17e2fd742.1490567803@imladris.local>
Download mbox | patch
Permalink /patch/19708/
State Accepted
Headers show

Comments

Augie Fackler - March 26, 2017, 10:36 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1490567390 14400
#      Sun Mar 26 18:29:50 2017 -0400
# Node ID 386820bf1ae17e2fd7425164c091065a39d21193
# Parent  8d683b05a16a94321d6c891ddc40f1bc3976db64
changelog: fix default open mode to use bytes io instead of str

Patch

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -126,7 +126,7 @@  class appender(object):
 
 def _divertopener(opener, target):
     """build an opener that writes in 'target.a' instead of 'target'"""
-    def _divert(name, mode='r', checkambig=False):
+    def _divert(name, mode='rb', checkambig=False):
         if name != target:
             return opener(name, mode)
         return opener(name + ".a", mode)
@@ -134,7 +134,7 @@  def _divertopener(opener, target):
 
 def _delayopener(opener, target, buf):
     """build an opener that stores chunks in 'buf' instead of 'target'"""
-    def _delay(name, mode='r', checkambig=False):
+    def _delay(name, mode='rb', checkambig=False):
         if name != target:
             return opener(name, mode)
         return appender(opener, name, mode, buf)