summaryrefslogtreecommitdiff
path: root/bs4/element.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/element.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/element.py')
-rw-r--r--bs4/element.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/bs4/element.py b/bs4/element.py
index 7f25f27..9b54d43 100644
--- a/bs4/element.py
+++ b/bs4/element.py
@@ -786,7 +786,7 @@ class PageElement(object):
string = kwargs.pop('text')
warnings.warn(
"The 'text' argument to find()-type methods is deprecated. Use 'string' instead.",
- DeprecationWarning
+ DeprecationWarning, stacklevel=3
)
if isinstance(name, SoupStrainer):
@@ -1562,7 +1562,7 @@ class Tag(PageElement):
'.%(name)sTag is deprecated, use .find("%(name)s") instead. If you really were looking for a tag called %(name)sTag, use .find("%(name)sTag")' % dict(
name=tag_name
),
- DeprecationWarning
+ DeprecationWarning, stacklevel=2
)
return self.find(tag_name)
# We special case contents to avoid recursion.
@@ -1997,7 +1997,7 @@ class Tag(PageElement):
"""
warnings.warn(
'has_key is deprecated. Use has_attr(key) instead.',
- DeprecationWarning
+ DeprecationWarning, stacklevel=2
)
return self.has_attr(key)
@@ -2028,7 +2028,7 @@ class SoupStrainer(object):
string = kwargs.pop('text')
warnings.warn(
"The 'text' argument to the SoupStrainer constructor is deprecated. Use 'string' instead.",
- DeprecationWarning
+ DeprecationWarning, stacklevel=2
)
self.name = self._normalize_search_value(name)