Thanks for the report.
HTMLParser.error() was supposed to raise an exception, but the BeautifulSoup project just prints a warning here:
def error(self, msg):
warnings.warn(msg)
https://bazaar.launchpad.net/~leonardr/beautifulsoup/bs4/view/head:/bs4/builder/_htmlparser.py#L69
As a result of this, the code doesn't stop executing in the following branch:
else:
self.error('unknown status keyword %r in marked section' % rawdata[i+3:j])
if not match:
return -1
https://github.com/python/cpython/blob/3.7/Lib/_markupbase.py#L159
Note that HTMLParser.error() was removed in Python 3.5 (https://github.com/python/cpython/commit/73a4359eb0eb624c588c5d52083ea4944f9787ea#diff-1a7486df8279dbac7f20abd487947845L171) and there is an open issue about the status of _markupbase.ParserBase.error(): Issue 31844.
I also think that https://github.com/python/cpython/commit/73a4359eb0eb624c588c5d52083ea4944f9787ea#diff-1a7486df8279dbac7f20abd487947845L171 may have caused a minor regression when it was removed the error() method and its uses from the HTMLParser class. It still calls the parse_marked_section() method of _markupbase.ParserBase() which it then calls the error() method of _markupbase.ParserBase():
elif rawdata[i:i+3] == '<![':
return self.parse_marked_section(i)
https://github.com/python/cpython/blob/3.7/Lib/html/parser.py#L264 |