D6103: py3: use pycompat.iterbytestr to convert memoryview slice to bytestring before passing to itertools.takewhile

Kwan (Ian Moody) phabricator at mercurial-scm.org
Thu Mar 14 11:41:00 EDT 2019


Kwan updated this revision to Diff 14494.
Kwan retitled this revision from "py3: use pycompat.iterbytestr to convert itertools.takewhile result back to bytes" to "py3: use pycompat.iterbytestr to convert memoryview slice to bytestring before passing to itertools.takewhile".
Kwan edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6103?vs=14416&id=14494

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(itertools.takewhile(
+            lambda ch: ch not in special,
+            pycompat.iterbytestr(view[pos:])
+        ))
         if symbol:
             yield (b'symbol', symbol, pos)
             pos += len(symbol)



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


More information about the Mercurial-devel mailing list