From 2966334d384946c16a104b6c9964a1999b23b838 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Fri, 24 Feb 2012 10:37:47 -0500 Subject: Warn when SoupStrainer is used with the html5lib tree builder. --- bs4/builder/_html5lib.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'bs4/builder/_html5lib.py') diff --git a/bs4/builder/_html5lib.py b/bs4/builder/_html5lib.py index 26b1773..cf716df 100644 --- a/bs4/builder/_html5lib.py +++ b/bs4/builder/_html5lib.py @@ -2,6 +2,7 @@ __all__ = [ 'HTML5TreeBuilder', ] +import warnings from bs4.builder import ( PERMISSIVE, HTML, @@ -30,6 +31,8 @@ class HTML5TreeBuilder(HTMLTreeBuilder): # These methods are defined by Beautiful Soup. def feed(self, markup): + if self.soup.parse_only is not None: + warnings.warn("You provided a value for parse_only, but the html5lib tree builder doesn't support parse_only. The entire document will be parsed.") parser = html5lib.HTMLParser(tree=self.create_treebuilder) doc = parser.parse(markup, encoding=self.user_specified_encoding) -- cgit v1.2.3