Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bad character range in a file skip glob #2145

Closed
peternewman opened this issue Nov 11, 2021 · 0 comments · Fixed by #2159
Closed

bad character range in a file skip glob #2145

peternewman opened this issue Nov 11, 2021 · 0 comments · Fixed by #2159
Labels

Comments

@peternewman
Copy link
Collaborator

Also, as result codespell --skip "example file with actual [weird signs in it and b-a]" goes down with

Traceback (most recent call last):
  File "/home/mateusz/.local/bin/codespell", line 8, in <module>
    sys.exit(_script_main())
  File "/home/mateusz/.local/lib/python3.8/site-packages/codespell_lib/_codespell.py", line 748, in _script_main
    return main(*sys.argv[1:])
  File "/home/mateusz/.local/lib/python3.8/site-packages/codespell_lib/_codespell.py", line 876, in main
    if glob_match.match(root):  # skip (absolute) directories
  File "/home/mateusz/.local/lib/python3.8/site-packages/codespell_lib/_codespell.py", line 108, in match
    if fnmatch.fnmatch(filename, p):
  File "/usr/lib/python3.8/fnmatch.py", line 36, in fnmatch
    return fnmatchcase(name, pat)
  File "/usr/lib/python3.8/fnmatch.py", line 70, in fnmatchcase
    match = _compile_pattern(pat)
  File "/usr/lib/python3.8/fnmatch.py", line 46, in _compile_pattern
    return re.compile(res).match
  File "/usr/lib/python3.8/re.py", line 252, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python3.8/re.py", line 304, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.8/sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.8/sre_parse.py", line 948, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "/usr/lib/python3.8/sre_parse.py", line 443, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/usr/lib/python3.8/sre_parse.py", line 834, in _parse
    p = _parse_sub(source, state, sub_verbose, nested + 1)
  File "/usr/lib/python3.8/sre_parse.py", line 443, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/usr/lib/python3.8/sre_parse.py", line 598, in _parse
    raise source.error(msg, len(this) + 1 + len(that))
re.error: bad character range b-a at position 56

_Originally posted by @matkoniecz in #2142 (comment)

While that glob obviously won't work, we probably shouldn't crash quite so unhelpfully and instead catch the error...

@peternewman peternewman changed the title bad character range in a skip bad character range in a file skip glob Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant