From e933f57798ad97cd76fdc0424bcb93318b1b9409 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 30 Aug 2013 08:27:28 +0530 Subject: [PATCH] newdb: Do not error out if the db contains null entries in the authors table --- src/calibre/db/cache.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py index fc1dd0ef3c..10ce4e75f5 100644 --- a/src/calibre/db/cache.py +++ b/src/calibre/db/cache.py @@ -1289,11 +1289,15 @@ class Cache(object): string. ''' table = self.fields['authors'].table result = [] - rmap = {icu_lower(v):k for k, v in table.id_map.iteritems()} + try: + rmap = {icu_lower(v):k for k, v in table.id_map.iteritems()} + except AttributeError: + # Somehow, the authors table has some authors that are None. Corrupted db? + rmap = {icu_lower(v or ''):k for k, v in table.id_map.iteritems()} for aut in authors: aid = rmap.get(icu_lower(aut), None) result.append(author_to_author_sort(aut) if aid is None else table.asort_map[aid]) - return ' & '.join(result) + return ' & '.join(filter(None, result)) @read_api def has_book(self, mi):