markup: allow better lxml import failure detection.

- in some conditions previous syntaxt could cause errors in first import.
This commit is contained in:
Marcin Kuzminski 2017-08-04 00:18:59 +02:00
parent b98b5eaaa8
commit ff01b29445

View file

@ -77,6 +77,13 @@ def relative_links(html_source, server_path):
if not html_source:
return html_source
try:
from lxml.html import fromstring
from lxml.html import tostring
except ImportError:
log.exception('Failed to import lxml')
return html_source
try:
doc = lxml.html.fromstring(html_source)
except Exception: