Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions twython/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
dealing with the Twitter API
"""

from __future__ import generator_stop
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure if this import is actually needed.

import warnings
import re

Expand Down Expand Up @@ -501,7 +502,7 @@ def cursor(self, function, return_pages=False, **params):
content = function(**params)

if not content:
raise StopIteration
return

if hasattr(function, 'iter_key'):
results = content.get(function.iter_key)
Expand All @@ -516,7 +517,7 @@ def cursor(self, function, return_pages=False, **params):

if function.iter_mode == 'cursor' and \
content['next_cursor_str'] == '0':
raise StopIteration
return

try:
if function.iter_mode == 'id':
Expand All @@ -529,7 +530,7 @@ def cursor(self, function, return_pages=False, **params):
params = dict(parse_qsl(next_results.query))
else:
# No more results
raise StopIteration
return
else:
# Twitter gives tweets in reverse chronological order:
params['max_id'] = str(int(content[-1]['id_str']) - 1)
Expand Down