Skip to content

Commit

Permalink
Avoid bailing out with uncaught PermissionError
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Dec 11, 2021
1 parent d8948ad commit 1fb04f6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,13 @@ def parse_file(filename, colors, summary, misspellings, exclude_lines,
if not os.path.isfile(filename):
return bad_count

text = is_text_file(filename)
try:
text = is_text_file(filename)
except (OSError, PermissionError) as e:
print("WARNING: %s: %s" % (e.strerror, filename),
file=sys.stderr)
return bad_count

if not text:
if not options.quiet_level & QuietLevels.BINARY_FILE:
print("WARNING: Binary file: %s" % filename, file=sys.stderr)
Expand Down

0 comments on commit 1fb04f6

Please sign in to comment.