diff options
Diffstat (limited to 'chromium/third_party/catapult/third_party/beautifulsoup4/bs4/builder/_htmlparser.py')
-rw-r--r-- | chromium/third_party/catapult/third_party/beautifulsoup4/bs4/builder/_htmlparser.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/chromium/third_party/catapult/third_party/beautifulsoup4/bs4/builder/_htmlparser.py b/chromium/third_party/catapult/third_party/beautifulsoup4/bs4/builder/_htmlparser.py index ca8d8b892bf..504a901c737 100644 --- a/chromium/third_party/catapult/third_party/beautifulsoup4/bs4/builder/_htmlparser.py +++ b/chromium/third_party/catapult/third_party/beautifulsoup4/bs4/builder/_htmlparser.py @@ -1,13 +1,18 @@ """Use the HTMLParser library to parse HTML files that aren't too bad.""" +from __future__ import absolute_import +from six import unichr +import six __all__ = [ 'HTMLParserTreeBuilder', ] -from HTMLParser import ( - HTMLParser, - HTMLParseError, - ) +from six.moves.html_parser import HTMLParser +if six.PY2: + from six.moves.html_parser import HTMLParseError +else: + class HTMLParseError(Exception): + pass import sys import warnings @@ -73,7 +78,7 @@ class BeautifulSoupHTMLParser(HTMLParser): try: data = unichr(real_name) - except (ValueError, OverflowError), e: + except (ValueError, OverflowError) as e: data = u"\N{REPLACEMENT CHARACTER}" self.handle_data(data) @@ -142,7 +147,7 @@ class HTMLParserTreeBuilder(HTMLTreeBuilder): declared within markup, whether any characters had to be replaced with REPLACEMENT CHARACTER). """ - if isinstance(markup, unicode): + if isinstance(markup, six.text_type): yield (markup, None, None, False) return @@ -158,7 +163,7 @@ class HTMLParserTreeBuilder(HTMLTreeBuilder): parser.soup = self.soup try: parser.feed(markup) - except HTMLParseError, e: + except HTMLParseError as e: warnings.warn(RuntimeWarning( "Python's built-in HTMLParser cannot parse the given document. This is not a bug in Beautiful Soup. The best solution is to install an external parser (lxml or html5lib), and use Beautiful Soup with that parser. See http://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser for help.")) raise e |