From d0cfb5568293d3ce878bc85cb6a268e1081759d4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 27 Jan 2014 20:20:55 +0530 Subject: [PATCH] ... --- src/calibre/ebooks/docx/to_html.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/docx/to_html.py b/src/calibre/ebooks/docx/to_html.py index 1ac03840cb..1b1622d219 100644 --- a/src/calibre/ebooks/docx/to_html.py +++ b/src/calibre/ebooks/docx/to_html.py @@ -376,10 +376,13 @@ class Convert(object): def p_parent(x): # Ensure that nested tags are handled. These can occur if a # textbox is present inside a paragraph. - while x is not None: + while True: x = x.getparent() - if x.tag.endswith('}p'): - return x + try: + if x.tag.endswith('}p'): + return x + except AttributeError: + break for x in descendants(p, 'w:r', 'w:bookmarkStart', 'w:hyperlink'): if p_parent(x) is not p: