Skip to content

Commit 4f6e849

Browse files
committed
catch spell check exception
1 parent 2283ae2 commit 4f6e849

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

codespell.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def spell_check_file(filename, spell_checker, mimetype='',
6767
spell_checker.set_text(c.text())
6868

6969
for error in spell_checker:
70+
if output_lvl > 1:
71+
print("Error:", error.word)
7072

7173
# Check if the bad word starts with a prefix.
7274
# If so, spell check the word without that prefix.
@@ -75,9 +77,12 @@ def spell_check_file(filename, spell_checker, mimetype='',
7577
if error.word.startswith(pre):
7678
wrd = error.word[len(pre):]
7779
if output_lvl > 1:
78-
print("Trying without prefix: ", wrd)
79-
if spell_checker.check(wrd):
80-
continue
80+
print("Trying without prefix: ", error.word, wrd)
81+
try:
82+
if spell_checker.check(wrd):
83+
continue
84+
except BaseException:
85+
print("Caught an exception for word", error.word, wrd)
8186

8287
# Try splitting camel case words and checking each sub-word
8388

0 commit comments

Comments
 (0)