summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2018-07-21 12:50:29 -0400
committerLeonard Richardson <leonardr@segfault.org>2018-07-21 12:50:29 -0400
commit81f853622f808fba7cd89d02ec524abc8588f196 (patch)
tree2505aa8a7b79b727936fd257dbca1a2f7a1467fc
parent70210f7ddef2d4a6aa8cb090c6f520a294012417 (diff)
downloadbeautifulsoup4-81f853622f808fba7cd89d02ec524abc8588f196.tar.gz
Clarified the deprecation warning when accessing tag.fooTag, to cover
the possibility that you might really have been looking for a tag called 'fooTag'.
-rw-r--r--NEWS.txt4
-rw-r--r--bs4/element.py6
2 files changed, 8 insertions, 2 deletions
diff --git a/NEWS.txt b/NEWS.txt
index ecaccad..1aa0a42 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -36,6 +36,10 @@
an attribute like 'name' that would otherwise be masked by another
argument of new_tag. [bug=1779276]
+* Clarified the deprecation warning when accessing tag.fooTag, to cover
+ the possibility that you might really have been looking for a tag
+ called 'fooTag'.
+
= 4.6.0 (20170507) =
* Added the `Tag.get_attribute_list` method, which acts like `Tag.get` for
diff --git a/bs4/element.py b/bs4/element.py
index f010833..c431a97 100644
--- a/bs4/element.py
+++ b/bs4/element.py
@@ -1106,8 +1106,10 @@ class Tag(PageElement):
# BS3: soup.aTag -> "soup.find("a")
tag_name = tag[:-3]
warnings.warn(
- '.%sTag is deprecated, use .find("%s") instead.' % (
- tag_name, tag_name))
+ '.%(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
+ )
+ )
return self.find(tag_name)
# We special case contents to avoid recursion.
elif not tag.startswith("__") and not tag == "contents":