# Buggy code
def _parse_files(self, filepath, override=False):
    """Parse files from a glob

    :param str filepath: Nginx config file path
    :param bool override: Whether to parse a file that has been parsed
    :returns: list of parsed tree structures
    :rtype: list

    """
    files = glob.glob(filepath)  # nginx on unix calls glob(3) for this
    # XXX Windows nginx uses FindFirstFile, and
    # should have a narrower call here
    trees = []
    for item in files:
        if item in self.parsed and not override:
            continue
        try:
            with open(item) as _file:
                parsed = nginxparser.load(_file)
                self.parsed[item] = parsed
                trees.append(parsed)
        except IOError:
            logger.warning("Could not open file: %s", item)
        except pyparsing.ParseException as err:
            logger.debug("Could not parse file: %s due to %s", item, err)
    return trees


# Traceback (UnicodeDecodeError)
2017-12-18 20:21:34,224:DEBUG:certbot.main:certbot version: 0.20.0
2017-12-18 20:21:34,235:DEBUG:certbot.main:Arguments: ['--nginx']
2017-12-18 20:21:34,243:DEBUG:certbot.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#nginx,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2017-12-18 20:21:34,417:DEBUG:certbot.log:Root logging level set at 20
2017-12-18 20:21:34,427:INFO:certbot.log:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2017-12-18 20:21:34,434:DEBUG:certbot.plugins.selection:Requested authenticator nginx and installer nginx
2017-12-18 20:21:34,742:DEBUG:certbot.log:Exiting abnormally:
Traceback (most recent call last):
File "/usr/bin/certbot", line 11, in <module>
load_entry_point('certbot==0.20.0', 'console_scripts', 'certbot')()
File "/usr/lib/python3.6/site-packages/certbot/main.py", line 861, in main
return config.func(config, plugins)
File "/usr/lib/python3.6/site-packages/certbot/main.py", line 685, in run
installer, authenticator = plug_sel.choose_configurator_plugins(config, plugins, "run")
File "/usr/lib/python3.6/site-packages/certbot/plugins/selection.py", line 189, in choose_configurator_plugins
authenticator = installer = pick_configurator(config, req_inst, plugins)
File "/usr/lib/python3.6/site-packages/certbot/plugins/selection.py", line 25, in pick_configurator
(interfaces.IAuthenticator, interfaces.IInstaller))
File "/usr/lib/python3.6/site-packages/certbot/plugins/selection.py", line 77, in pick_plugin
verified.prepare()
File "/usr/lib/python3.6/site-packages/certbot/plugins/disco.py", line 248, in prepare
return [plugin_ep.prepare() for plugin_ep in six.itervalues(self._plugins)]
File "/usr/lib/python3.6/site-packages/certbot/plugins/disco.py", line 248, in <listcomp>
return [plugin_ep.prepare() for plugin_ep in six.itervalues(self._plugins)]
File "/usr/lib/python3.6/site-packages/certbot/plugins/disco.py", line 130, in prepare
self._initialized.prepare()
File "/usr/lib/python3.6/site-packages/certbot_nginx/configurator.py", line 156, in prepare
self.parser = parser.NginxParser(self.conf('server-root'))
File "/usr/lib/python3.6/site-packages/certbot_nginx/parser.py", line 35, in __init__
self.load()
File "/usr/lib/python3.6/site-packages/certbot_nginx/parser.py", line 42, in load
self._parse_recursively(self.config_root)
File "/usr/lib/python3.6/site-packages/certbot_nginx/parser.py", line 63, in _parse_recursively
self._parse_recursively(subentry[1])
File "/usr/lib/python3.6/site-packages/certbot_nginx/parser.py", line 53, in _parse_recursively
trees = self._parse_files(filepath)
File "/usr/lib/python3.6/site-packages/certbot_nginx/parser.py", line 203, in _parse_files
parsed = nginxparser.load(_file)
File "/usr/lib/python3.6/site-packages/certbot_nginx/nginxparser.py", line 122, in load
return loads(_file.read())
File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 10453: ordinal not in range(128)
2017-12-18 20:21:34,759:ERROR:certbot.log:An unexpected error occurred:

# Fixed code
def _parse_files(self, filepath, override=False):
    """Parse files from a glob

    :param str filepath: Nginx config file path
    :param bool override: Whether to parse a file that has been parsed
    :returns: list of parsed tree structures
    :rtype: list

    """
    files = glob.glob(filepath)  # nginx on unix calls glob(3) for this
    # XXX Windows nginx uses FindFirstFile, and
    # should have a narrower call here
    trees = []
    for item in files:
        if item in self.parsed and not override:
            continue
        try:
            with io.open(item, "r", encoding="utf-8") as _file:
                parsed = nginxparser.load(_file)
                self.parsed[item] = parsed
                trees.append(parsed)
        except IOError:
            logger.warning("Could not open file: %s", item)
        except UnicodeDecodeError:
            logger.warning(
                "Could not read file: %s due to invalid "
                "character. Only UTF-8 encoding is "
                "supported.",
                item,
            )
        except pyparsing.ParseException as err:
            logger.debug("Could not parse file: %s due to %s", item, err)
    return trees