[lxml-dev] Some HTML target processing issues

Stefan Behnel stefan_ml at behnel.de
Sat Aug 23 09:25:36 CEST 2008


Hi,

Max Ivanov wrote:
> Here is one test for problem with not calling targets' close() method
> when XMLSyntaxError is raised during SAX-like parsing even with
> recover=True. This is addition to test_htmlparser.py:
> 
> 
>    def test_module_target_on_raise_stop(self):
>        class Target(object):
>            def __init__(self, res):
>                self.res = res
>            def start(self, tag, attrib):
>                pass
>            def end(self, tag):
>                pass
>            def close(self):
>                self.res.append(True)
> 
>        result = []
>        parser = self.etree.HTMLParser(target=Target(result), recover=True)
>        parse = self.etree.parse
>        f = BytesIO(self.broken_html_str)
>        self.assertRaises(self.etree.XMLSyntaxError,
>                          parse, f, parser)
>        self.assertEqual(result[-1],True)

Thanks, could you file a bug report in the launchpad bug tracker so that this
doesn't get lost?

Stefan



More information about the lxml-dev mailing list