summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2012-02-09 08:13:42 -0500
committerLeonard Richardson <leonard.richardson@canonical.com>2012-02-09 08:13:42 -0500
commitec3d55d62ddf86ba220b8acdafa5a33a74acaebb (patch)
tree10061183f5a42ae4b07b1893917d35ec53bc06a7
parent600f332672763518033de253997a6e21fde07f44 (diff)
Fixed a bug that caused a crash when you passed a dictionary as an attribute value (possibly because you mistyped attrs). [bug=842419]
-rw-r--r--NEWS.txt3
-rw-r--r--bs4/element.py5
2 files changed, 7 insertions, 1 deletions
diff --git a/NEWS.txt b/NEWS.txt
index 31cfdbe..461f49d 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -14,6 +14,9 @@
object to search against a tag's CSS classes. Previously this only
worked if you passed in a string.
+* Fixed a bug that caused a crash when you passed a dictionary as an
+ attribute value (possibly because you mistyped "attrs"). [bug=842419]
+
= 4.0.0b4 (20120208) =
* Added BeautifulSoup.new_string() to go along with BeautifulSoup.new_tag()
diff --git a/bs4/element.py b/bs4/element.py
index ff7c972..c053181 100644
--- a/bs4/element.py
+++ b/bs4/element.py
@@ -1030,7 +1030,10 @@ class SoupStrainer(object):
and not isinstance(match_against, basestring)):
result = markup in match_against
elif hasattr(match_against, 'items'):
- result = match_against in markup
+ if markup is None:
+ result = len(match_against.items()) == 0
+ else:
+ result = match_against in markup
elif match_against and isinstance(markup, basestring):
match_against = markup.__class__(match_against)