diff options
| author | Anthony Sottile <asottile@umich.edu> | 2017-10-09 09:23:08 -0700 |
|---|---|---|
| committer | Anthony Sottile <asottile@umich.edu> | 2017-10-09 09:52:37 -0700 |
| commit | bbe8d6d6c6bb91363f2947f5c05edecb141074dc (patch) | |
| tree | 623388bf5fe5b7a7658e7738b3170ecb2d11f574 /src | |
| parent | 2e12a2024b525e94ff9f864e101160bf226d048b (diff) | |
| download | flake8-bbe8d6d6c6bb91363f2947f5c05edecb141074dc.tar.gz | |
Catch UnicodeDecodeError while parsing config files
Diffstat (limited to 'src')
| -rw-r--r-- | src/flake8/options/config.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/flake8/options/config.py b/src/flake8/options/config.py index 7e770b6..71429af 100644 --- a/src/flake8/options/config.py +++ b/src/flake8/options/config.py @@ -60,13 +60,21 @@ class ConfigFileFinder(object): @staticmethod def _read_config(files): config = configparser.RawConfigParser() - try: - found_files = config.read(files) - except configparser.ParsingError: - LOG.exception("There was an error trying to parse a config " - "file. The files we were attempting to parse " - "were: %r", files) - found_files = [] + if isinstance(files, (str, type(u''))): + files = [files] + + found_files = [] + for filename in files: + try: + found_files.extend(config.read(filename)) + except UnicodeDecodeError: + LOG.exception("There was an error decoding a config file." + "The file with a problem was %s.", + filename) + except configparser.ParsingError: + LOG.exception("There was an error trying to parse a config " + "file. The file with a problem was %s.", + filename) return (config, found_files) def cli_config(self, files): |
