Skip to content

Commit 9d1a2d9

Browse files
committed
Fix error when enabling spell checking without a file with personal list of words
1 parent 84378b2 commit 9d1a2d9

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

msgcheck/po.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,14 @@ def _get_language_checker(self, po_file, reports):
495495
lang = po_file.props['language'] \
496496
if self.spelling == 'str' else 'en'
497497
try:
498-
with tempfile.NamedTemporaryFile() as tmp_file:
499-
tmp_file.write(self.pwl.encode('utf-8'))
500-
tmp_file.flush()
501-
_dict = DictWithPWL(lang, tmp_file.name)
502-
checker.append(SpellChecker(_dict))
498+
if self.pwl:
499+
with tempfile.NamedTemporaryFile() as tmp_file:
500+
tmp_file.write(self.pwl.encode('utf-8'))
501+
tmp_file.flush()
502+
_dict = DictWithPWL(lang, tmp_file.name)
503+
else:
504+
_dict = DictWithPWL(lang, None)
505+
checker.append(SpellChecker(_dict))
503506
except DictNotFoundError:
504507
reports.append(PoReport(
505508
'enchant dictionary not found for language "{0}"'

0 commit comments

Comments
 (0)