From 504644e641aad3e0ef8ebe73152f6415a7214bcb Mon Sep 17 00:00:00 2001 From: miruka Date: Wed, 24 Jul 2019 19:56:23 -0400 Subject: [PATCH] Fix JSONConfigFile read() when no file exists --- src/python/config_files.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/python/config_files.py b/src/python/config_files.py index 678eecf1..21aa36ff 100644 --- a/src/python/config_files.py +++ b/src/python/config_files.py @@ -34,10 +34,7 @@ class ConfigFile: async def read(self): - try: - return self.path.read_text() - except FileNotFoundError: - return await self.default_data() + return self.path.read_text() async def write(self, data) -> None: @@ -57,7 +54,7 @@ class JSONConfigFile(ConfigFile): async def read(self) -> JsonData: try: data = json.loads(await super().read()) - except json.JSONDecodeError: + except (FileNotFoundError, json.JSONDecodeError): data = {} all_data = await self.default_data()