From dd5661fab6c7b8ae352d58a411d3dcf1aaeaa45d Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Wed, 8 May 2013 12:30:32 -0400 Subject: Minor cleanup. --- bs4/element.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bs4/element.py b/bs4/element.py index e7f4af9..21e040a 100644 --- a/bs4/element.py +++ b/bs4/element.py @@ -1264,6 +1264,8 @@ class Tag(PageElement): if self.count == self.destination: return True if self.count > self.destination: + # Stop the generator that's sending us + # these things. raise StopIteration() return False checker = Counter(pseudo_value).nth_child_of_type @@ -1360,6 +1362,8 @@ class Tag(PageElement): try: result = checker(candidate) except StopIteration: + # The checker has decided we should no longer + # run the generator. break if checker is None or result: if self._select_debug: -- cgit v1.2.3