From da90da98e3dcf73c855ceac5edc9092608dafed3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 12 May 2011 09:07:29 -0600 Subject: [PATCH] Handle people with legacy databases that have custom columns with non ascii search names. Fixes #781490 (KeyError happens whenever I click on a book in the main screen (list)) --- src/calibre/ebooks/metadata/book/base.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/metadata/book/base.py b/src/calibre/ebooks/metadata/book/base.py index 7927517b22..ceb6751238 100644 --- a/src/calibre/ebooks/metadata/book/base.py +++ b/src/calibre/ebooks/metadata/book/base.py @@ -112,10 +112,15 @@ class Metadata(object): Be careful with numeric fields since this will return True for zero as well as None. + + Also returns True if the field does not exist. ''' - null_val = NULL_VALUES.get(field, None) - val = getattr(self, field, None) - return not val or val == null_val + try: + null_val = NULL_VALUES.get(field, None) + val = getattr(self, field, None) + return not val or val == null_val + except: + return True def __getattribute__(self, field): _data = object.__getattribute__(self, '_data')