diff -r bf5f777260a6 -r 21b0534faebc eric6/ThirdParty/Pygments/pygments/formatters/__init__.py --- a/eric6/ThirdParty/Pygments/pygments/formatters/__init__.py Tue Apr 21 19:44:19 2020 +0200 +++ b/eric6/ThirdParty/Pygments/pygments/formatters/__init__.py Tue Apr 21 19:47:10 2020 +0200 @@ -5,7 +5,7 @@ Pygments formatters. - :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ @@ -17,7 +17,7 @@ from pygments.formatters._mapping import FORMATTERS from pygments.plugin import find_plugin_formatters -from pygments.util import ClassNotFound, itervalues +from pygments.util import ClassNotFound __all__ = ['get_formatter_by_name', 'get_formatter_for_filename', 'get_all_formatters', 'load_formatter_from_file'] + list(FORMATTERS) @@ -45,7 +45,7 @@ def get_all_formatters(): """Return a generator for all formatter classes.""" # NB: this returns formatter classes, not info like get_all_lexers(). - for info in itervalues(FORMATTERS): + for info in FORMATTERS.values(): if info[1] not in _formatter_cache: _load_formatters(info[0]) yield _formatter_cache[info[1]] @@ -58,7 +58,7 @@ Returns None if not found. """ - for module_name, name, aliases, _, _ in itervalues(FORMATTERS): + for module_name, name, aliases, _, _ in FORMATTERS.values(): if alias in aliases: if name not in _formatter_cache: _load_formatters(module_name) @@ -98,7 +98,8 @@ try: # This empty dict will contain the namespace for the exec'd file custom_namespace = {} - exec(open(filename, 'rb').read(), custom_namespace) + with open(filename, 'rb') as f: + exec(f.read(), custom_namespace) # Retrieve the class `formattername` from that namespace if formattername not in custom_namespace: raise ClassNotFound('no valid %s class found in %s' % @@ -107,8 +108,8 @@ # And finally instantiate it with the options return formatter_class(**options) except IOError as err: - raise ClassNotFound('cannot read %s' % filename) - except ClassNotFound as err: + raise ClassNotFound('cannot read %s: %s' % (filename, err)) + except ClassNotFound: raise except Exception as err: raise ClassNotFound('error when loading custom formatter: %s' % err) @@ -120,7 +121,7 @@ Raises ClassNotFound if not found. """ fn = basename(fn) - for modname, name, _, filenames, _ in itervalues(FORMATTERS): + for modname, name, _, filenames, _ in FORMATTERS.values(): for filename in filenames: if _fn_matches(fn, filename): if name not in _formatter_cache: