For loop in twython search results raises StopIteration #522

Closed
opened 2019-11-12 12:19:34 -08:00 by brambo23 · 9 comments
brambo23 commented 2019-11-12 12:19:34 -08:00 (Migrated from github.com)

Hello,

I'm very new at python and I'm trying to search the results of my twitter query.

When I do, once the end of the generator is reached, my entire code stops from a runtime error raised by a StopIteration.

Upon researching, this is a new thing in Python 3.7 (which is what I'm using for this project) where instead of just continuing on once a StopIteration has been met, it stops the entire script from running.

So my question is, are there any ways to either provide a list of how many results there are or a way to exception out the StopIteration from presenting itself so I can continue running my code?

Thank you in advance

Hello, I'm very new at python and I'm trying to search the results of my twitter query. When I do, once the end of the generator is reached, my entire code stops from a runtime error raised by a StopIteration. Upon researching, this is a new thing in Python 3.7 (which is what I'm using for this project) where instead of just continuing on once a StopIteration has been met, it stops the entire script from running. So my question is, are there any ways to either provide a list of how many results there are or a way to exception out the StopIteration from presenting itself so I can continue running my code? Thank you in advance
ThisIsNoahEvans commented 2019-11-16 05:11:36 -08:00 (Migrated from github.com)

I have this same issue. It's quite annoying.

I have this same issue. It's quite annoying.
RaitoBezarius commented 2019-11-16 07:40:28 -08:00 (Migrated from github.com)

I think I can send a PR, it just requires removing explicit raising of StopIteration and replacing by a return.

A current workaround consists in catching all runtime errors, and doing 'generator raised StopIteration' in str(e) and swallowing this exception otherwise re-raising it.

Relevant PEP: https://www.python.org/dev/peps/pep-0479/

I think I can send a PR, it just requires removing explicit raising of StopIteration and replacing by a `return`. A current workaround consists in catching all runtime errors, and doing `'generator raised StopIteration' in str(e)` and swallowing this exception otherwise re-raising it. Relevant PEP: https://www.python.org/dev/peps/pep-0479/
alxndr42 commented 2020-02-04 14:39:04 -08:00 (Migrated from github.com)

Also running into this with Python 3.7. The last commit is from April 2019, is this project still maintained?

Also running into this with Python 3.7. The last commit is from April 2019, is this project still maintained?
ryanmcgrath commented 2020-02-04 14:46:08 -08:00 (Migrated from github.com)

Hmmm, @RaitoBezarius is that offer for a PR still good?

Real life (+ most of my projects not being in Python these days) means this isn't seeing as much attention as is ideal... but I can try to carve out time to merge some outstanding PRs and bug fixes if they're lined up.

I'm also happy to grant someone else access to the project to help with this stuff. Pretty sure we've come close to finding people before but generally fizzles out... such is the nature of open source work sometimes.

Hmmm, @RaitoBezarius is that offer for a PR still good? Real life (+ most of my projects not being in Python these days) means this isn't seeing as much attention as is ideal... but I can try to carve out time to merge some outstanding PRs and bug fixes if they're lined up. I'm also happy to grant someone else access to the project to help with this stuff. Pretty sure we've come close to finding people before but generally fizzles out... such is the nature of open source work sometimes.
RaitoBezarius commented 2020-02-04 15:10:33 -08:00 (Migrated from github.com)

@ryanmcgrath Of course! :)
Though, I would love to give a hand whenever I can, but I'm not sure this qualify to granting me access to the project :) — I'm myself a prisoner of real life :P

@ryanmcgrath Of course! :) Though, I would love to give a hand whenever I can, but I'm not sure this qualify to granting me access to the project :) — I'm myself a prisoner of real life :P
michaelhelmick commented 2020-02-07 08:31:18 -08:00 (Migrated from github.com)

I second this, sorry to all; I just haven't had the time to invest in this project in the recent years :(

I second this, sorry to all; I just haven't had the time to invest in this project in the recent years :(
ryanmcgrath commented 2020-04-02 23:53:47 -07:00 (Migrated from github.com)

@RaitoBezarius Heya, did you still want to look at a PR here?

@RaitoBezarius Heya, did you still want to look at a PR here?
edvilme commented 2020-10-15 14:57:38 -07:00 (Migrated from github.com)

Hello, I am still having the same issue on python 3.8.5

Hello, I am still having the same issue on python 3.8.5
edvilme commented 2020-10-15 14:58:35 -07:00 (Migrated from github.com)

If you want, I can do a little digging and do a PR, but also wanted to know if anyone found a workaround

If you want, I can do a little digging and do a PR, but also wanted to know if anyone found a workaround
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: code/twython#522
No description provided.