##// END OF EJS Templates
py3: avoid iterating over a literal bytes in highlight...
py3: avoid iterating over a literal bytes in highlight In Python 3, iterating over a bytes literal yields integers. Since we use the value in `text.replace()`, this fails on Python 3 with the following trackback: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/mercurial/hgweb/hgwebdir_mod.py", line 378, in run_wsgi for r in self._runwsgi(req, res): File "/usr/lib/python3/dist-packages/mercurial/hgweb/hgweb_mod.py", line 326, in run_wsgi for r in self._runwsgi(req, res, repo): File "/usr/lib/python3/dist-packages/mercurial/hgweb/hgweb_mod.py", line 449, in _runwsgi return getattr(webcommands, cmd)(rctx) File "/usr/lib/python3/dist-packages/mercurial/hgweb/webcommands.py", line 211, in file return _filerevision(web, webutil.filectx(web.repo, web.req)) File "/usr/lib/python3/dist-packages/hgext/highlight/__init__.py", line 72, in filerevision_highlight pygmentize(web, b'fileline', fctx, web.tmpl) File "/usr/lib/python3/dist-packages/hgext/highlight/__init__.py", line 58, in pygmentize field, fctx, style, tmpl, guessfilenameonly=filenameonly File "/usr/lib/python3/dist-packages/hgext/highlight/highlight.py", line 62, in pygmentize text = text.replace(c, b'') TypeError: a bytes-like object is required, not 'int'

File last commit:

r43346:2372284d default
r44014:856cce0c stable
Show More
manifest_corpus.py
33 lines | 1.3 KiB | text/x-python | PythonLexer
from __future__ import absolute_import, print_function
import argparse
import zipfile
ap = argparse.ArgumentParser()
ap.add_argument("out", metavar="some.zip", type=str, nargs=1)
args = ap.parse_args()
with zipfile.ZipFile(args.out[0], "w", zipfile.ZIP_STORED) as zf:
zf.writestr(
"manifest_zero",
'''PKG-INFO\09b3ed8f2b81095a13064402e930565f083346e9a
README\080b6e76643dcb44d4bc729e932fc464b3e36dbe3
hg\0b6444347c629cc058d478023905cfb83b7f5bb9d
mercurial/__init__.py\0b80de5d138758541c5f05265ad144ab9fa86d1db
mercurial/byterange.py\017f5a9fbd99622f31a392c33ac1e903925dc80ed
mercurial/fancyopts.py\0b6f52e23e356748c5039313d8b639cda16bf67ba
mercurial/hg.py\023cc12f225f1b42f32dc0d897a4f95a38ddc8f4a
mercurial/mdiff.py\0a05f65c44bfbeec6a42336cd2ff0b30217899ca3
mercurial/revlog.py\0217bc3fde6d82c0210cf56aeae11d05a03f35b2b
mercurial/transaction.py\09d180df101dc14ce3dd582fd998b36c98b3e39aa
notes.txt\0703afcec5edb749cf5cec67831f554d6da13f2fb
setup.py\0ccf3f6daf0f13101ca73631f7a1769e328b472c9
tkmerge\03c922edb43a9c143682f7bc7b00f98b3c756ebe7
''',
)
zf.writestr("badmanifest_shorthashes", "narf\0aa\nnarf2\0aaa\n")
zf.writestr(
"badmanifest_nonull",
"narf\0cccccccccccccccccccccccccccccccccccccccc\n"
"narf2aaaaaaaaaaaaaaaaaaaa\n",
)