diff options
-rw-r--r-- | bs4/element.py | 4 |
1 files changed, 4 insertions, 0 deletions
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: |