From bb147d741388895899d1b153896ad6a12ef8f987 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 6 Jun 2017 20:54:47 +0530 Subject: [PATCH] Fix #1696145 [EBook Converter Crashes on CSS Parsing](https://bugs.launchpad.net/calibre/+bug/1696145) --- src/calibre/ebooks/oeb/stylizer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/oeb/stylizer.py b/src/calibre/ebooks/oeb/stylizer.py index bfe6e50ca4..c791b093d0 100644 --- a/src/calibre/ebooks/oeb/stylizer.py +++ b/src/calibre/ebooks/oeb/stylizer.py @@ -418,7 +418,10 @@ class Style(object): self._style.update(self._stylizer.flatten_style(style)) def _has_parent(self): - return (self._element.getparent() is not None) + try: + return self._element.getparent() is not None + except AttributeError: + return False # self._element is None def _get_parent(self): elem = self._element.getparent() @@ -770,4 +773,3 @@ class Style(object): @property def is_hidden(self): return self._style.get('display') == 'none' or self._style.get('visibility') == 'hidden' -