Mercurial > public > mercurial-scm > hg-stable
diff mercurial/pycompat.py @ 31391:c9fd842dc886
pycompat: add helper to iterate each char in bytes
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 12 Mar 2017 17:04:45 -0700 |
parents | 06440ba06bc0 |
children | 1ed169c5e235 |
line wrap: on
line diff
--- a/mercurial/pycompat.py Sun Mar 12 19:47:51 2017 -0400 +++ b/mercurial/pycompat.py Sun Mar 12 17:04:45 2017 -0700 @@ -76,6 +76,10 @@ def bytechr(i): return bytes([i]) + def iterbytestr(s): + """Iterate bytes as if it were a str object of Python 2""" + return iter(s[i:i + 1] for i in range(len(s))) + def sysstr(s): """Return a keyword str to be passed to Python functions such as getattr() and str.encode() @@ -142,6 +146,7 @@ import cStringIO bytechr = chr + iterbytestr = iter def sysstr(s): return s