Merge pull request #540 from zseri/fix4pep479

Fix #522 (needed bc of PEP 479)
This commit is contained in:
Ryan McGrath 2021-07-16 13:10:28 -07:00 committed by GitHub
commit e8306c4834
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,6 +9,7 @@ Twitter Authentication, and miscellaneous methods that are useful when
dealing with the Twitter API dealing with the Twitter API
""" """
from __future__ import generator_stop
import warnings import warnings
import re import re
@ -501,7 +502,7 @@ class Twython(EndpointsMixin, object):
content = function(**params) content = function(**params)
if not content: if not content:
raise StopIteration return
if hasattr(function, 'iter_key'): if hasattr(function, 'iter_key'):
results = content.get(function.iter_key) results = content.get(function.iter_key)
@ -516,7 +517,7 @@ class Twython(EndpointsMixin, object):
if function.iter_mode == 'cursor' and \ if function.iter_mode == 'cursor' and \
content['next_cursor_str'] == '0': content['next_cursor_str'] == '0':
raise StopIteration return
try: try:
if function.iter_mode == 'id': if function.iter_mode == 'id':
@ -529,7 +530,7 @@ class Twython(EndpointsMixin, object):
params = dict(parse_qsl(next_results.query)) params = dict(parse_qsl(next_results.query))
else: else:
# No more results # No more results
raise StopIteration return
else: else:
# Twitter gives tweets in reverse chronological order: # Twitter gives tweets in reverse chronological order:
params['max_id'] = str(int(content[-1]['id_str']) - 1) params['max_id'] = str(int(content[-1]['id_str']) - 1)