diff --git a/src/calibre/utils/config_base.py b/src/calibre/utils/config_base.py index 16751de47c..e2908ba0d5 100644 --- a/src/calibre/utils/config_base.py +++ b/src/calibre/utils/config_base.py @@ -610,12 +610,20 @@ def exec_tweaks(path): def read_custom_tweaks(): make_config_dir() tf = tweaks_file() + ans = {} if os.path.exists(tf): with open(tf, 'rb') as f: raw = f.read() - return json_loads(raw) + raw = raw.strip() + if not raw: + return ans + try: + return json_loads(raw) + except Exception: + import traceback + traceback.print_exc() + return ans old_tweaks_file = tf.rpartition(u'.')[0] + u'.py' - ans = {} if os.path.exists(old_tweaks_file): ans = exec_tweaks(old_tweaks_file) ans = make_unicode(ans)