Patchwork D7129: py3: don't index into bytes in phabricator's _tokenize()

login
register
mail settings
Submitter phabricator
Date Oct. 17, 2019, 11:31 p.m.
Message ID <differential-rev-PHID-DREV-bzjij5f5fxndjwo525rv-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42462/
State Superseded
Headers show

Comments

phabricator - Oct. 17, 2019, 11:31 p.m.
Kwan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  `phabread`ing a stack using `hg phabread :D1234` under py3 will currently die
  with a KeyError because it will index into `b':D1234'` and return `58` instead
  of `b':'` as a token.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7129

AFFECTED FILES
  hgext/phabricator.py

CHANGE DETAILS




To: Kwan, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -1274,8 +1274,8 @@ 
             yield (b'symbol', symbol, pos)
             pos += len(symbol)
         else:  # special char, ignore space
-            if text[pos] != b' ':
-                yield (text[pos], None, pos)
+            if text[pos : pos + 1] != b' ':
+                yield (text[pos : pos + 1], None, pos)
             pos += 1
     yield (b'end', None, pos)