Patchwork [4,of,8] py3: slice over bytes to prevent getting it's ascii value

login
register
mail settings
Submitter Pulkit Goyal
Date June 26, 2017, 7:55 p.m.
Message ID <7fa40e5656821b8ed20b.1498506925@workspace>
Download mbox | patch
Permalink /patch/21745/
State Accepted
Headers show

Comments

Pulkit Goyal - June 26, 2017, 7:55 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1498360011 -19800
#      Sun Jun 25 08:36:51 2017 +0530
# Node ID 7fa40e5656821b8ed20b31e62c37ad6245656d0d
# Parent  34b6d0746a92388e10751b8bff90a7b7bb22b1f4
py3: slice over bytes to prevent getting it's ascii value

Patch

diff --git a/mercurial/fancyopts.py b/mercurial/fancyopts.py
--- a/mercurial/fancyopts.py
+++ b/mercurial/fancyopts.py
@@ -39,7 +39,7 @@ 
     args = []
     while parseargs:
         arg = parseargs.pop(0)
-        if arg and arg[0] == '-' and len(arg) > 1:
+        if arg and arg[0:1] == '-' and len(arg) > 1:
             parseargs.insert(0, arg)
             topts, newparseargs = pycompat.getoptb(parseargs,\
                                             options, longoptions)
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -182,7 +182,7 @@ 
 
 if os.path.isdir('.hg'):
     cmd = [sys.executable, 'hg', 'log', '-r', '.', '--template', '{tags}\n']
-    numerictags = [t for t in runhg(cmd, env).split() if t[0].isdigit()]
+    numerictags = [t for t in runhg(cmd, env).split() if t[0:1].isdigit()]
     hgid = runhg([sys.executable, 'hg', 'id', '-i'], env).strip()
     if numerictags: # tag(s) found
         version = numerictags[-1]