From 7095e33100119bec1ff0f3764803c62a39605a1f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 30 Mar 2011 15:20:50 -0600 Subject: [PATCH] Fix #746043 (Conversion from specific LRF books gives "RuntimeError: maximum recursion depth exceeded") --- src/calibre/ebooks/lrf/input.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/lrf/input.py b/src/calibre/ebooks/lrf/input.py index 70f3c3a15a..e354bee562 100644 --- a/src/calibre/ebooks/lrf/input.py +++ b/src/calibre/ebooks/lrf/input.py @@ -6,7 +6,7 @@ __license__ = 'GPL v3' __copyright__ = '2009, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import os, textwrap +import os, textwrap, sys from copy import deepcopy from lxml import etree @@ -413,7 +413,12 @@ class LRFInput(InputFormatPlugin): ('calibre', 'image-block'): image_block, } transform = etree.XSLT(styledoc, extensions=extensions) - result = transform(doc) + try: + result = transform(doc) + except RuntimeError: + sys.setrecursionlimit(5000) + result = transform(doc) + with open('content.opf', 'wb') as f: f.write(result) styles.write()