Skip to content

Commit

Permalink
Merge pull request #737 from samuela/samuela/unicode-error
Browse files Browse the repository at this point in the history
Catch/report `UnicodeDecodeError`s in `ReadFile`

Closes #736
  • Loading branch information
bwendling committed Aug 6, 2019
2 parents f25e0e2 + b8e1d10 commit 5dde15d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -24,6 +24,7 @@
### Changed
- Set `INDENT_DICTIONARY_VALUE` for Google style.
- Set `JOIN_MULTIPLE_LINES = False` for Google style.
- Catch and report `UnicodeDecodeError` exceptions.
### Fixed
- `BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF=False` wasn't honored because the
number of newlines was erroneously calculated beforehand.
Expand Down
6 changes: 6 additions & 0 deletions yapf/yapflib/yapf_api.py
Expand Up @@ -202,6 +202,12 @@ def ReadFile(filename, logger=None):
if logger:
logger(err)
raise
except UnicodeDecodeError as err: # pragma: no cover
if logger:
logger('Could not parse %s! Consider excluding this file with --exclude.',
filename)
logger(err)
raise


def _SplitSemicolons(uwlines):
Expand Down

0 comments on commit 5dde15d

Please sign in to comment.