mirror of
https://github.com/python/cpython.git
synced 2025-08-07 18:38:38 +00:00
[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>
This commit is contained in:
parent
1699a5ee13
commit
518b238967
3 changed files with 26 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue