Fix #746043 (Conversion from specific LRF books gives "RuntimeError: maximum recursion depth exceeded")

This commit is contained in:
Kovid Goyal 2011-03-30 15:20:50 -06:00
parent df6fabfff4
commit 7095e33100

View File

@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>' __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import os, textwrap import os, textwrap, sys
from copy import deepcopy from copy import deepcopy
from lxml import etree from lxml import etree
@ -413,7 +413,12 @@ class LRFInput(InputFormatPlugin):
('calibre', 'image-block'): image_block, ('calibre', 'image-block'): image_block,
} }
transform = etree.XSLT(styledoc, extensions=extensions) transform = etree.XSLT(styledoc, extensions=extensions)
try:
result = transform(doc) result = transform(doc)
except RuntimeError:
sys.setrecursionlimit(5000)
result = transform(doc)
with open('content.opf', 'wb') as f: with open('content.opf', 'wb') as f:
f.write(result) f.write(result)
styles.write() styles.write()