Display the error line on HTMLParser parse errors.

This commit is contained in:
Jens Diemer
2012-05-18 18:07:18 +03:00
parent d6d030ec3c
commit 11ae55c90d

View File

@@ -15,7 +15,9 @@ class DefaultHtmlParser(ParserBase, HTMLParser):
self.feed(self.content)
self.close()
except Exception, err:
raise ParserError("Error while initializing HtmlParser: %s" % err)
lineno = err.lineno
line = self.content.splitlines()[lineno]
raise ParserError("Error while initializing HtmlParser: %s (line: %s)" % (err, repr(line)))
def handle_starttag(self, tag, attrs):
tag = tag.lower()