From 5ae77bc63799198e8f52d57b2f8f551d27ffce0b Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sat, 14 Sep 2019 13:41:56 +0200 Subject: [PATCH 1/2] Fix issue with spell language being None --- nw/config.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nw/config.py b/nw/config.py index ea1f4c2f..6dcaf7dd 100644 --- a/nw/config.py +++ b/nw/config.py @@ -219,6 +219,9 @@ class Config: for i in range(10): self.recentList[i] = self._parseLine(cnfParse, cnfSec, "recent%d" % i,self.CNF_STR, self.recentList[i]) + # Check Certain Values for None + self.spellLanguage = self._checkNone(self.spellLanguage) + return True def saveConfig(self): @@ -379,4 +382,12 @@ class Config: ) return cnfDefault + def _checkNone(self, checkVal): + if checkVal is None: + return None + if isinstance(checkVal, str): + if checkVal.lower == "none": + return None + return checkVal + # End Class Config From 38509299ae032b59214292a9c2f96b88dc32cbdc Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sat, 14 Sep 2019 13:44:51 +0200 Subject: [PATCH 2/2] Added try/except for setting dictionary --- nw/tools/spellenchant.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/nw/tools/spellenchant.py b/nw/tools/spellenchant.py index 61c9a012..4b56238d 100644 --- a/nw/tools/spellenchant.py +++ b/nw/tools/spellenchant.py @@ -32,11 +32,15 @@ class NWSpellEnchant(NWSpellCheck): return def setLanguage(self, theLang, projectDict=None): - if projectDict is None: - self.theDict = enchant.Dict(theLang) - else: - self.theDict = enchant.DictWithPWL(theLang, projectDict) - logger.debug("Enchant spell checking for language %s loaded" % theLang) + try: + if projectDict is None: + self.theDict = enchant.Dict(theLang) + else: + self.theDict = enchant.DictWithPWL(theLang, projectDict) + logger.debug("Enchant spell checking for language %s loaded" % theLang) + except: + logger.error("Failed to load enchant spell checking for language %s" % theLang) + self.theDict = None return def checkWord(self, theWord):