From: Aaron Hill Date: Sun, 13 Apr 2014 19:45:38 +0000 (-0400) Subject: Don't make an unnecessary API call in PageIterator X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1cdeae4d771ed99c1ae78402541f1ce5d22c251c;p=tweepy.git Don't make an unnecessary API call in PageIterator --- diff --git a/tweepy/cursor.py b/tweepy/cursor.py index ef81c52..451e849 100644 --- a/tweepy/cursor.py +++ b/tweepy/cursor.py @@ -133,10 +133,13 @@ class PageIterator(BaseIterator): self.current_page = 0 def next(self): - self.current_page += 1 + if self.limit > 0 and self.current_page > self.limit: + raise StopIteration + items = self.method(page=self.current_page, *self.args, **self.kargs) - if len(items) == 0 or (self.limit > 0 and self.current_page > self.limit): + if len(items) == 0: raise StopIteration + self.current_page += 1 return items def prev(self):