From ac5d96f7f38fae7f7ac6d30ec7056070fe6f8cc3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 5 Mar 2013 22:54:35 +0530 Subject: [PATCH] Book polishing: Do not error out when polishing epub files that have XML comments in their OPF metadata section. --- src/calibre/ebooks/oeb/polish/container.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/oeb/polish/container.py b/src/calibre/ebooks/oeb/polish/container.py index a793b58a04..5c5f296fe1 100644 --- a/src/calibre/ebooks/oeb/polish/container.py +++ b/src/calibre/ebooks/oeb/polish/container.py @@ -391,9 +391,12 @@ class Container(object): remove = set() for child in mdata: child.tail = '\n ' - if (child.get('name', '').startswith('calibre:') and - child.get('content', '').strip() in {'{}', ''}): - remove.add(child) + try: + if (child.get('name', '').startswith('calibre:') and + child.get('content', '').strip() in {'{}', ''}): + remove.add(child) + except AttributeError: + continue # Happens for XML comments for child in remove: mdata.remove(child) if len(mdata) > 0: mdata[-1].tail = '\n '