From b2eac6f919918cc5fc60fc588948c48cd806dd8c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 3 May 2015 09:38:44 +0530 Subject: [PATCH] ... --- src/calibre/ebooks/docx/writer/from_html.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/docx/writer/from_html.py b/src/calibre/ebooks/docx/writer/from_html.py index f310577fae..95282f3c43 100644 --- a/src/calibre/ebooks/docx/writer/from_html.py +++ b/src/calibre/ebooks/docx/writer/from_html.py @@ -296,7 +296,9 @@ class Blocks(object): self.pos = len(self.all_blocks) self.block_map = {} - def __exit__(self, *args): + def __exit__(self, etype, value, traceback): + if value is not None: + return # Since there was an exception, the data structures are not in a consistent state if self.current_block is not None: self.all_blocks.append(self.current_block) self.current_block = None