diff options
Diffstat (limited to 'pygments/formatters/__init__.py')
-rw-r--r-- | pygments/formatters/__init__.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/pygments/formatters/__init__.py b/pygments/formatters/__init__.py index 965c5f1a..4fa4178e 100644 --- a/pygments/formatters/__init__.py +++ b/pygments/formatters/__init__.py @@ -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. """ @@ -98,7 +98,8 @@ def load_formatter_from_file(filename, formattername="CustomFormatter", 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' % |