summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_htmlparser.py
diff options
context:
space:
mode:
authorMarek Suscak <marek.suscak@gmail.com>2022-05-16 16:19:04 (GMT)
committerGitHub <noreply@github.com>2022-05-16 16:19:04 (GMT)
commit518b2389673833887b26a8474eeb9530d17e2b8d (patch)
tree82c3aed4174705ba9d5290ae9e85f914c4042b18 /Lib/test/test_htmlparser.py
parent1699a5ee13a39da73f5d9a8c5def4438200b7b59 (diff)
downloadcpython-518b2389673833887b26a8474eeb9530d17e2b8d.zip
cpython-518b2389673833887b26a8474eeb9530d17e2b8d.tar.gz
cpython-518b2389673833887b26a8474eeb9530d17e2b8d.tar.bz2
[3.9] bpo-34480: fix bug where match variable is used prior to being defined (GH-17643) (GH-32256)
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Lib/test/test_htmlparser.py')
-rw-r--r--Lib/test/test_htmlparser.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py
index 1291775..44a76a4 100644
--- a/Lib/test/test_htmlparser.py
+++ b/Lib/test/test_htmlparser.py
@@ -787,5 +787,27 @@ class AttributesTestCase(TestCaseBase):
('starttag', 'form',
[('action', 'bogus|&#()value')])])
+ def test_invalid_keyword_error_exception(self):
+ # bpo-34480: check that subclasses that define an
+ # error method that raises an exception work
+ 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>')
+
+ def test_invalid_keyword_error_pass(self):
+ # bpo-34480: check that subclasses that define an
+ # error method that doesn't raise an exception work
+ class MyHTMLParser(html.parser.HTMLParser):
+ def error(self, message):
+ pass
+ parser = MyHTMLParser()
+ self.assertEqual(parser.feed('<![invalid>'), None)
+
+
if __name__ == "__main__":
unittest.main()