# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2017-03-07 19:10:15 # Node ID f8e06821c1188fb878c8176d331eb73c191f9309 # Parent 4cc3797aa59cd3ebcdcc85e1668d973a3e72ecf4 store: slice over a bytestring to get characters instead of ascii values On Python 2, >>> a = b'abc' >>> a[1] 'b' Whereas on python 3, >>> a = b'abc' >>> a[1] 98 >>> a[1:2] b'b' This does not change behaviour on python 2. diff --git a/mercurial/store.py b/mercurial/store.py --- a/mercurial/store.py +++ b/mercurial/store.py @@ -101,7 +101,7 @@ def _buildencodefun(): e = '_' if pycompat.ispy3: xchr = lambda x: bytes([x]) - asciistr = [bytes(a) for a in range(127)] + asciistr = [bytes([a]) for a in range(127)] else: xchr = chr asciistr = map(chr, xrange(127)) @@ -128,7 +128,7 @@ def _buildencodefun(): pass else: raise KeyError - return (lambda s: ''.join([cmap[c] for c in s]), + return (lambda s: ''.join([cmap[s[c:c + 1]] for c in xrange(len(s))]), lambda s: ''.join(list(decode(s)))) _encodefname, _decodefname = _buildencodefun()