From 21afbdc1d6247ed77697c31e50653f230ae4bfd5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 30 Oct 2019 08:28:14 +0530 Subject: [PATCH] py3: Fix #1850571 [[Python3] kobo driver fails to load](https://bugs.launchpad.net/calibre/+bug/1850571) --- src/calibre/devices/kobo/driver.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/devices/kobo/driver.py b/src/calibre/devices/kobo/driver.py index f7ba01e0f9..10135eaeab 100644 --- a/src/calibre/devices/kobo/driver.py +++ b/src/calibre/devices/kobo/driver.py @@ -408,7 +408,7 @@ class KOBO(USBMS): # Remove books that are no longer in the filesystem. Cache contains # indices into the booklist if book not in filesystem, None otherwise # Do the operation in reverse order so indices remain valid - for idx in sorted(itervalues(bl_cache), reverse=True): + for idx in sorted(itervalues(bl_cache), reverse=True, key=lambda x: x or -1): if idx is not None: need_sync = True del bl[idx] @@ -1971,7 +1971,7 @@ class KOBOTOUCH(KOBO): # Remove books that are no longer in the filesystem. Cache contains # indices into the booklist if book not in filesystem, None otherwise # Do the operation in reverse order so indices remain valid - for idx in sorted(itervalues(bl_cache), reverse=True): + for idx in sorted(itervalues(bl_cache), reverse=True, key=lambda x: x or -1): if idx is not None: if not os.path.exists(self.normalize_path(os.path.join(prefix, bl[idx].lpath))) or not bl[idx].contentID: need_sync = True