ThirdParty/Pygments/pygments/__init__.py

changeset 4172
4f20dba37ab6
parent 3145
a9de05d4a22f
child 4697
c2e9bf425554
--- a/ThirdParty/Pygments/pygments/__init__.py	Wed Mar 11 18:25:37 2015 +0100
+++ b/ThirdParty/Pygments/pygments/__init__.py	Wed Mar 11 18:32:27 2015 +0100
@@ -22,13 +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-2014 by the Pygments team, see AUTHORS.
     :license: BSD, see LICENSE for details.
 """
 
-from __future__ import unicode_literals
-
-__version__ = '1.6'
+__version__ = '2.0.2'
 __docformat__ = 'restructuredtext'
 
 __all__ = ['lex', 'format', 'highlight']
@@ -47,7 +45,8 @@
         return lexer.get_tokens(code)
     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
@@ -63,15 +62,15 @@
     """
     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 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
@@ -88,6 +87,6 @@
     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))

eric ide

mercurial