From 91c7ac997cc476fe9ad4765f3615efcd879b9749 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 6 Oct 2009 09:38:08 -0600 Subject: [PATCH] IGN:Handle failure to parse to decode config files gracefully. --- src/calibre/utils/config.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/config.py b/src/calibre/utils/config.py index e7bc06e7af..c9424717f0 100644 --- a/src/calibre/utils/config.py +++ b/src/calibre/utils/config.py @@ -411,7 +411,11 @@ class Config(ConfigInterface): if os.path.exists(self.config_file_path): try: with ExclusiveFile(self.config_file_path) as f: - src = f.read().decode('utf-8') + try: + src = f.read().decode('utf-8') + except ValueError: + print "Failed to parse", self.config_file_path + traceback.print_exc() except LockError: raise IOError('Could not lock config file: %s'%self.config_file_path) return self.option_set.parse_string(src)