summaryrefslogtreecommitdiff
path: root/bs4/element.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2013-05-07 12:12:24 -0400
committerLeonard Richardson <leonardr@segfault.org>2013-05-07 12:12:24 -0400
commit716ef11451f833227b5ba30b4324335e057c4e52 (patch)
treef61513efe83c038cedc7cf3443f7a601d32737e6 /bs4/element.py
parent1cd5ad49b15d17fac017543876ec5d0a67b57b69 (diff)
Fixed an exception when an overspecified CSS selector didn't match
anything. Code by Stefaan Lippens. [bug=1168167]
Diffstat (limited to 'bs4/element.py')
-rw-r--r--bs4/element.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/bs4/element.py b/bs4/element.py
index 67f2a79..2834fcb 100644
--- a/bs4/element.py
+++ b/bs4/element.py
@@ -638,6 +638,9 @@ class PageElement(object):
tag, id = token.split('#', 1)
if tag == "":
tag = True
+ if len(current_context) == 0:
+ # No match.
+ return []
el = current_context[0].find(tag, {'id': id})
if el is None:
return [] # No match