PEP 479: Change StopIteration handling inside generators
This commit is contained in:
parent
8e004f5d89
commit
1a54c15a71
1 changed files with 3 additions and 3 deletions
|
|
@ -501,7 +501,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 +516,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 +529,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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue