From 74380c3685d0fe730bcb06e63d8591e65b557df5 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Mon, 3 Jun 2013 09:45:11 -0400 Subject: Changed _popToTag to run through a single range instead of two. --- bs4/__init__.py | 9 +++------ 1 file 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): -- cgit v1.2.3