Skip to content

codespell fails with uncaught exception on empty files #2194

@DimitriPapadopoulos

Description

@DimitriPapadopoulos
$ mkdir -p foo
$ touch foo/bar.sql
$ 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 754, in _script_main
    return main(*sys.argv[1:])
  File "/my/path/codespell/codespell_lib/_codespell.py", line 905, in main
    bad_count += parse_file(
  File "/my/path/codespell/codespell_lib/_codespell.py", line 642, in parse_file
    lines, encoding = file_opener.open(filename)
  File "/my/path/codespell/codespell_lib/_codespell.py", line 174, in open
    return self.open_with_internal(filename)
  File "/my/path/codespell/codespell_lib/_codespell.py", line 223, in open_with_internal
    raise Exception('Unknown encoding: %s' % filename)
Exception: Unknown encoding
$ 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions