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

Kwan (Ian Moody) phabricator at mercurial-scm.org
Thu Oct 17 23:31:02 UTC 2019


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

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)
 



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


More information about the Mercurial-devel mailing list