From 6ce3059322b14bf0267e8ad4adb0f28da06e1d26 Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 6 Oct 2020 23:18:33 -0400 Subject: [PATCH] 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. --- src/backend/user_files.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/backend/user_files.py b/src/backend/user_files.py index 373eebb6..5dcdeb47 100644 --- a/src/backend/user_files.py +++ b/src/backend/user_files.py @@ -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 = {} - + loaded = json.loads(data) all_data = self.default_data.copy() dict_update_recursive(all_data, loaded) return (all_data, loaded != all_data)