summaryrefslogtreecommitdiff
path: root/bs4/builder/_html5lib.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2023-01-27 12:45:14 -0500
committerLeonard Richardson <leonardr@segfault.org>2023-01-27 12:45:14 -0500
commit98756d3c97f553f7abf22e3e16a357dac60f0b02 (patch)
treea30d5bdc90e4639053b037cd1b6a8e8d81deb63e /bs4/builder/_html5lib.py
parent12ad184120ad7ddebe63462daf3c6f1a64fb4338 (diff)
Warnings now do their best to provide an appropriate stacklevel,
improving the usefulness of the message. [bug=1978744]
Diffstat (limited to 'bs4/builder/_html5lib.py')
-rw-r--r--bs4/builder/_html5lib.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/bs4/builder/_html5lib.py b/bs4/builder/_html5lib.py
index 12dee07..dac2173 100644
--- a/bs4/builder/_html5lib.py
+++ b/bs4/builder/_html5lib.py
@@ -70,7 +70,10 @@ class HTML5TreeBuilder(HTMLTreeBuilder):
# ATM because the html5lib TreeBuilder doesn't use
# UnicodeDammit.
if exclude_encodings:
- warnings.warn("You provided a value for exclude_encoding, but the html5lib tree builder doesn't support exclude_encoding.")
+ warnings.warn(
+ "You provided a value for exclude_encoding, but the html5lib tree builder doesn't support exclude_encoding.",
+ stacklevel=3
+ )
# html5lib only parses HTML, so if it's given XML that's worth
# noting.
@@ -81,7 +84,10 @@ 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.")
+ 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.",
+ stacklevel=4
+ )
parser = html5lib.HTMLParser(tree=self.create_treebuilder)
self.underlying_builder.parser = parser
extra_kwargs = dict()