Skip to content

Commit

Permalink
Merge pull request #3457 from nyalldawson/pygments
Browse files Browse the repository at this point in the history
Upgrade internal pygments to 2.1.3
  • Loading branch information
nyalldawson authored Sep 5, 2016
2 parents e1f21b0 + 82da555 commit 1671536
Show file tree
Hide file tree
Showing 180 changed files with 64,592 additions and 20,991 deletions.
21 changes: 11 additions & 10 deletions python/ext-libs/pygments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
.. _Pygments tip:
http://bitbucket.org/birkenfeld/pygments-main/get/tip.zip#egg=Pygments-dev
:copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
:copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""

__version__ = '1.6'
__version__ = '2.1.3'
__docformat__ = 'restructuredtext'

__all__ = ['lex', 'format', 'highlight']
Expand All @@ -43,15 +43,16 @@ def lex(code, lexer):
"""
try:
return lexer.get_tokens(code)
except TypeError, err:
except TypeError as err:
if isinstance(err.args[0], str) and \
'unbound method get_tokens' in err.args[0]:
('unbound method get_tokens' in err.args[0] or
'missing 1 required positional argument' in err.args[0]):
raise TypeError('lex() argument must be a lexer instance, '
'not a class')
raise


def format(tokens, formatter, outfile=None):
def format(tokens, formatter, outfile=None): # pylint: disable=redefined-builtin
"""
Format a tokenlist ``tokens`` with the formatter ``formatter``.
Expand All @@ -61,15 +62,15 @@ def format(tokens, formatter, outfile=None):
"""
try:
if not outfile:
#print formatter, 'using', formatter.encoding
realoutfile = formatter.encoding and BytesIO() or StringIO()
realoutfile = getattr(formatter, 'encoding', None) and BytesIO() or StringIO()
formatter.format(tokens, realoutfile)
return realoutfile.getvalue()
else:
formatter.format(tokens, outfile)
except TypeError, err:
except TypeError as err:
if isinstance(err.args[0], str) and \
'unbound method format' in err.args[0]:
('unbound method format' in err.args[0] or
'missing 1 required positional argument' in err.args[0]):
raise TypeError('format() argument must be a formatter instance, '
'not a class')
raise
Expand All @@ -86,6 +87,6 @@ def highlight(code, lexer, formatter, outfile=None):
return format(lex(code, lexer), formatter, outfile)


if __name__ == '__main__':
if __name__ == '__main__': # pragma: no cover
from pygments.cmdline import main
sys.exit(main(sys.argv))
Loading

0 comments on commit 1671536

Please sign in to comment.