From patchwork Thu Feb 16 16:35:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [py3] ui: construct _keepalnum list in a python3-friendly way From: Augie Fackler X-Patchwork-Id: 18547 Message-Id: <791b4e846a7b9a078344.1487262941@arthedain.pit.corp.google.com> To: mercurial-devel@mercurial-scm.org Cc: Martijn Pieters Date: Thu, 16 Feb 2017 11:35:41 -0500 # HG changeset patch # User Augie Fackler # Date 1487262890 18000 # Thu Feb 16 11:34:50 2017 -0500 # Node ID 791b4e846a7b9a0783440b9504585438777fe2d2 # Parent 1ee685defe80117cf6aafea1ede6c33c478abceb ui: construct _keepalnum list in a python3-friendly way It'll be more expensive, but it preserves the behavior. diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -36,7 +36,12 @@ from . import ( urlreq = util.urlreq # for use with str.translate(None, _keepalnum), to keep just alphanumerics -_keepalnum = ''.join(c for c in map(chr, range(256)) if not c.isalnum()) +if pycompat.ispy3: + _unicodes = [bytes([c]).decode('latin1') for c in range(256)] + _notalnum = [s.encode('latin1') for s in _unicodes if not s.isalnum()] +else: + _notalnum = [c for c in map(chr, range(256)) if not c.isalnum()] +_keepalnum = ''.join(_notalnum) samplehgrcs = { 'user':