diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py index 86cc2c07b19..9640a8c2df1 100644 --- a/codespell_lib/_codespell.py +++ b/codespell_lib/_codespell.py @@ -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)