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

login
register
mail settings
Submitter Augie Fackler
Date Sept. 16, 2017, 12:34 a.m.
Message ID <33c529f19fdf5dbecc7e.1505522044@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/23931/
State Accepted
Headers show

Comments

Augie Fackler - Sept. 16, 2017, 12:34 a.m.
# HG changeset patch
# User Augie Fackler <raf@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

Patch

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