Raise error if loading a JSON fails

Don't use the default config if there's an error in a JSON config file,
a single typo could lead to an entire user settings file getting
overwritten by default data.
This commit is contained in:
miruka 2020-10-06 23:18:33 -04:00
parent 75fbf23b21
commit 6ce3059322

View File

@ -188,11 +188,7 @@ class JSONFile(MappingFile):
returned dict and the second tuple item will be `True`.
"""
try:
loaded = json.loads(data)
except json.JSONDecodeError:
loaded = {}
all_data = self.default_data.copy()
dict_update_recursive(all_data, loaded)
return (all_data, loaded != all_data)