From 1cdeae4d771ed99c1ae78402541f1ce5d22c251c Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sun, 13 Apr 2014 15:45:38 -0400 Subject: [PATCH] Don't make an unnecessary API call in PageIterator --- tweepy/cursor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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): -- 2.25.1