Skip to content

codespell fails with uncaught exception on unreadable files #2189

Closed

Description

@DimitriPapadopoulos
$ mkdir -p foo/bar
$ touch foo/bar/file
$ chmod a= foo/bar/file
$ cd foo
$ 
$ codespell 
Traceback (most recent call last):
  File "/home/username/.local/bin/codespell", line 11, in <module>
    load_entry_point('codespell', 'console_scripts', 'codespell')()
  File "/my/path/codespell/codespell_lib/_codespell.py", line 746, in _script_main
    return main(*sys.argv[1:])
  File "/my/path/codespell/codespell_lib/_codespell.py", line 897, in main
    bad_count += parse_file(
  File "/my/path/codespell/codespell_lib/_codespell.py", line 630, in parse_file
    text = is_text_file(filename)
  File "/my/path/codespell/codespell_lib/_codespell.py", line 488, in is_text_file
    with open(filename, mode='rb') as f:
PermissionError: [Errno 13] Permission denied: './bar/file'
$ 

Activity

  1. peternewman commented on Dec 8, 2021

    @peternewman
    Collaborator

    Nice find, another warning to add like the missing files.

  2. DimitriPapadopoulos commented on Dec 8, 2021

    @DimitriPapadopoulos
    CollaboratorAuthor

    It could fail silently (as it does on files deleted after os.walk()) or emit a warning. In this case, I agree with you: we require a warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions