Patchwork [1,of,3,py3] py3: wrap bytes in encoding.from/toutf8b() with bytestr

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 16, 2017, 2:32 p.m.
Message ID <9835dada78098e86e057.1505572370@mimosa>
Download mbox | patch
Permalink /patch/23944/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 16, 2017, 2:32 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1504421669 -32400
#      Sun Sep 03 15:54:29 2017 +0900
# Node ID 9835dada78098e86e057cf20ee0ee5ec2efe3dab
# Parent  9003f4dc016c5900d02db7a77a0d55d205cffc13
py3: wrap bytes in encoding.from/toutf8b() with bytestr

Patch

diff --git a/mercurial/encoding.py b/mercurial/encoding.py
--- a/mercurial/encoding.py
+++ b/mercurial/encoding.py
@@ -508,6 +508,7 @@  def toutf8b(s):
         except UnicodeDecodeError:
             pass
 
+    s = pycompat.bytestr(s)
     r = ""
     pos = 0
     l = len(s)
@@ -560,6 +561,7 @@  def fromutf8b(s):
     # points to be escaped. Instead, we use our handy getutf8char
     # helper again to walk the string without "decoding" it.
 
+    s = pycompat.bytestr(s)
     r = ""
     pos = 0
     l = len(s)