Skip deprecated lexers (Pygments 2.7.3 and later)

Work around the way Pygments maintainers have decided to list
"deprecated" lexers, but just skipping them if attempting to add
raises an IndexError because they look like JSONBareObject here:

https: //github.com/pygments/pygments/commit/5ee1754
Change-Id: Ia7b896263b4118ec369c5ce130addef3295a91a5
This commit is contained in:
Jeremy Stanley 2021-02-01 20:14:51 +00:00
parent 1970b75415
commit 69ec973e39
2 changed files with 7 additions and 2 deletions

View File

@ -35,7 +35,12 @@ def _get_pygments_lexers(add_empty=True):
if add_empty:
r.append(('', ''),)
for lexer in get_all_lexers():
r.append((lexer[1][0], _(lexer[0])),)
try:
r.append((lexer[1][0], _(lexer[0])),)
except IndexError:
# Skip "deprecated" lexer entries, like this in Pygments 2.7.3:
# https://github.com/pygments/pygments/commit/5ee1754
continue
return r

View File

@ -2,7 +2,7 @@ six
Jinja2
Werkzeug<0.16
Pygments<2.6;python_version<'3'
Pygments<2.7.3;python_version>='3'
Pygments;python_version>='3'
SQLAlchemy
PyMySQL
simplejson