[PATCH 2 of 4 python3] encoding: ensure getutf8char always returns a bytestr, never an int

Augie Fackler raf at durin42.com
Fri Sep 15 20:34:04 EDT 2017


# HG changeset patch
# User Augie Fackler <raf at durin42.com>
# Date 1505519012 14400
#      Fri Sep 15 19:43:32 2017 -0400
# Node ID 33c529f19fdf5dbecc7e2853e8eabaac4cc347e2
# Parent  34469e4e2187381259d78ec0a35c2dd5b0e9e85a
encoding: ensure getutf8char always returns a bytestr, never an int

diff --git a/mercurial/encoding.py b/mercurial/encoding.py
--- a/mercurial/encoding.py
+++ b/mercurial/encoding.py
@@ -458,9 +458,9 @@ def getutf8char(s, pos):
     '''
 
     # find how many bytes to attempt decoding from first nibble
-    l = _utf8len[ord(s[pos]) >> 4]
+    l = _utf8len[ord(s[pos:pos + 1]) >> 4]
     if not l: # ascii
-        return s[pos]
+        return s[pos:pos + 1]
 
     c = s[pos:pos + l]
     # validate with attempted decode


More information about the Mercurial-devel mailing list