Patchwork [01,of,10] py3: use pycompat.bytechr instead of chr

login
register
mail settings
Submitter Pulkit Goyal
Date May 4, 2017, 10:46 p.m.
Message ID <28e7209f8d5fd3525b43.1493938006@pulkit-goyal>
Download mbox | patch
Permalink /patch/20440/
State Accepted
Headers show

Comments

Pulkit Goyal - May 4, 2017, 10:46 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1493806071 -19800
#      Wed May 03 15:37:51 2017 +0530
# Node ID 28e7209f8d5fd3525b435eccd8ab78813531b6db
# Parent  1a7b0c03484b45834c842b33e44c7c58257e1e9d
py3: use pycompat.bytechr instead of chr
Yuya Nishihara - May 5, 2017, 10:36 a.m.
On Fri, 05 May 2017 04:16:46 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1493806071 -19800
> #      Wed May 03 15:37:51 2017 +0530
> # Node ID 28e7209f8d5fd3525b435eccd8ab78813531b6db
> # Parent  1a7b0c03484b45834c842b33e44c7c58257e1e9d
> py3: use pycompat.bytechr instead of chr

Queued 1,2, 5-10, thanks.

Patch

diff -r 1a7b0c03484b -r 28e7209f8d5f mercurial/encoding.py
--- a/mercurial/encoding.py	Fri May 05 01:41:54 2017 +0530
+++ b/mercurial/encoding.py	Wed May 03 15:37:51 2017 +0530
@@ -429,7 +429,7 @@ 
 
 _jsonmap = []
 _jsonmap.extend("\\u%04x" % x for x in range(32))
-_jsonmap.extend(chr(x) for x in range(32, 127))
+_jsonmap.extend(pycompat.bytechr(x) for x in range(32, 127))
 _jsonmap.append('\\u007f')
 _jsonmap[0x09] = '\\t'
 _jsonmap[0x0a] = '\\n'
@@ -441,7 +441,7 @@ 
 _paranoidjsonmap = _jsonmap[:]
 _paranoidjsonmap[0x3c] = '\\u003c'  # '<' (e.g. escape "</script>")
 _paranoidjsonmap[0x3e] = '\\u003e'  # '>'
-_jsonmap.extend(chr(x) for x in range(128, 256))
+_jsonmap.extend(pycompat.bytechr(x) for x in range(128, 256))
 
 def jsonescape(s, paranoid=False):
     '''returns a string suitable for JSON