Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:
Attaching a test case for this issue since the self.error code path was not covered in the current test suite. A PR is open proposing match variable initialisation with None https://github.com/python/cpython/pull/17643 . diff --git Lib/test/test_htmlparser.py Lib/test/test_htmlparser.py index a2bfb39d16..a9aff11706 100644 --- Lib/test/test_htmlparser.py +++ Lib/test/test_htmlparser.py @@ -766,6 +766,18 @@ class AttributesTestCase(TestCaseBase): [("href", "http://www.example.org/\">;")]), ("data", "spam"), ("endtag", "a")]) + def test_invalid_keyword_error_exception(self): + class InvalidMarkupException(Exception): + pass + + class MyHTMLParser(html.parser.HTMLParser): + + def error(self, message): + raise InvalidMarkupException(message) + + parser = MyHTMLParser() + with self.assertRaises(InvalidMarkupException): + parser.feed('<![invalid>') if __name__ == "__main__": unittest.main() ---------- nosy: +xtreak _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34480> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com