Mongoengine: raise StopIteration in generators is deprecated

Created on 5 Sep 2017  路  8Comments  路  Source: MongoEngine/mongoengine

...
/Users/Vic/projects/brain2/brain/utils/user_progress.py:686: DeprecationWarning: generator 'QuerySet._iter_results' raised StopIteration
  for action in actions:
/Users/Vic/projects/brain2/brain/utils/user_course_state.py:317: DeprecationWarning: generator 'QuerySet._iter_results' raised StopIteration
  PlayedTask(
/Users/Vic/projects/brain2/venv/lib/python3.6/site-packages/mongoengine/dereference.py:33: DeprecationWarning: generator 'QuerySet._iter_results' raised StopIteration
...

https://stackoverflow.com/questions/14183803/in-pythons-generators-what-is-the-difference-between-raise-stopiteration-and

https://github.com/MongoEngine/mongoengine/blob/5bdd35464b89dd2def1dcb0464e244322f1bc757/mongoengine/queryset/queryset.py#L95

Most helpful comment

This issue is a blocker on Python 3.7. Probably best to release ASAP.

All 8 comments

I also have this problem when looping over a queryset.

for u in User.objects(name='John'):
    ...

DeprecationWarning: generator 'QuerySet._iter_results' raised StopIteration

Hey guys. I'm seeing this warning in my app as well. Basically I'm doing something like:

results = Entity.objects().order_by('-display_order')
return list(results)

Some way to fix this? AFAIK, I'm running the latest mongoegine on PyPI.

I think you don't need to. Just wait until the next release.

@mikeckennedy Nice podcast. Big fan.

Thank you @GNHua I appreciate the kind words on the podcast and feedback. My favorite way to fix my software is to simply wait around. ;)

Oh, BTW, one of the sites I had in mind when I commented here was https://talkpython.fm -- mongoengine is powering that one. Been a joy to work with.

Any update on this?

the issue still there with mongoengine 0.15.0

This issue is a blocker on Python 3.7. Probably best to release ASAP.

Was this page helpful?
0 / 5 - 0 ratings