This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author scoder
Recipients eli.bendersky, scoder
Date 2013-01-24.15:10:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1359040208.76.0.707549580683.issue17024@psf.upfronthosting.co.za>
In-reply-to
Content
The following compatibility unit test fails for me in lxml since Py3.3.

    etree = xml.etree.ElementTree

    def test_parser_target_error_in_start(self):
        assertEqual = self.assertEqual

        events = []
        class Target(object):
            def start(self, tag, attrib):
                events.append("start")
                assertEqual("TAG", tag)
                raise ValueError("TEST")
            def end(self, tag):
                events.append("end")
                assertEqual("TAG", tag)
            def close(self):
                return "DONE"

        parser = self.etree.XMLParser(target=Target())

        try:
            parser.feed("<TAG/>")
        except ValueError:
            self.assertTrue('TEST' in str(sys.exc_info()[1]))
        else:
            self.assertTrue(False)

        # ERROR HERE - gives ["start", "end"] in Py3.3
        self.assertEqual(["start"], events)

It seems like cET doesn't handle exceptions early enough and still calls the end() method. Neither Python ElementTree nor lxml do this.

Some more tests are here:

https://github.com/lxml/lxml/blob/master/src/lxml/tests/test_elementtree.py#L3446

(all tests in that file are known to work with ET)
History
Date User Action Args
2013-01-24 15:10:08scodersetrecipients: + scoder, eli.bendersky
2013-01-24 15:10:08scodersetmessageid: <1359040208.76.0.707549580683.issue17024@psf.upfronthosting.co.za>
2013-01-24 15:10:08scoderlinkissue17024 messages
2013-01-24 15:10:07scodercreate