D6103: py3: use pycompat.iterbytestr to convert itertools.takewhile result back to bytes

Kwan (Ian Moody) phabricator at mercurial-scm.org
Sat Mar 9 03:00:58 UTC 2019


Kwan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  itertools.takewhile on a bytestring returns the bytes as ints in py3, use
  iterbytestr to get the individual characters as bytestring like in py2.

REPOSITORY
  rHG Mercurial

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

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
@@ -671,8 +671,10 @@
     pos = 0
     length = len(text)
     while pos < length:
-        symbol = b''.join(itertools.takewhile(lambda ch: ch not in special,
-                                              view[pos:]))
+        symbol = b''.join(pycompat.iterbytestr(itertools.takewhile(
+            lambda ch: ch not in special,
+            view[pos:]
+        )))
         if symbol:
             yield (b'symbol', symbol, pos)
             pos += len(symbol)



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


More information about the Mercurial-devel mailing list