diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2013-06-03 09:45:11 -0400 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2013-06-03 09:45:11 -0400 |
commit | 74380c3685d0fe730bcb06e63d8591e65b557df5 (patch) | |
tree | e750b8b07dd2b6e681f9858b2ce4600b8a295e06 | |
parent | 87806d1b86e4bc65514a5652daaa2e893cbcdc1f (diff) |
Changed _popToTag to run through a single range instead of two.
-rw-r--r-- | bs4/__init__.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/bs4/__init__.py b/bs4/__init__.py index 3ca12ff..cd4a692 100644 --- a/bs4/__init__.py +++ b/bs4/__init__.py @@ -294,20 +294,17 @@ class BeautifulSoup(Tag): # The BeautifulSoup object itself can never be popped. return - num_pops = 0 most_recently_popped = None stack_size = len(self.tagStack) for i in range(stack_size - 1, 0, -1): t = self.tagStack[i] if (name == t.name and nsprefix == t.prefix): - num_pops = stack_size - i + if inclusivePop: + most_recently_popped = self.popTag() break - if not inclusivePop: - num_pops = num_pops - 1 - - for i in range(0, num_pops): most_recently_popped = self.popTag() + return most_recently_popped def handle_starttag(self, name, namespace, nsprefix, attrs): |