Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with Python 3.7 #1669

Merged
merged 1 commit into from Jul 15, 2018
Merged

Conversation

felixonmars
Copy link
Contributor

Fixes many test failures like below:

======================================================================
ERROR: test_iterator (tests.models.TestModelAPIs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/python-peewee/src/peewee-3.5.2/peewee.py", line 3613, in iterator
    yield self.iterate(False)
  File "/build/python-peewee/src/peewee-3.5.2/peewee.py", line 3597, in iterate
    raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/build/python-peewee/src/peewee-3.5.2/tests/base.py", line 247, in inner
    method(self)
  File "/build/python-peewee/src/peewee-3.5.2/tests/models.py", line 989, in test_iterator
    self.assertEqual([u.username for u in query], users)
  File "/build/python-peewee/src/peewee-3.5.2/tests/models.py", line 989, in <listcomp>
    self.assertEqual([u.username for u in query], users)
RuntimeError: generator raised StopIteration

With the patch, all tests pass under both python 3.7 and 2.7 here.

@coleifer
Copy link
Owner

Thanks. So you can't raise StopIteration inside a generator according to this PEP... weird. I'm guessing this is some consequence from the asyncio abomination.

Currently, StopIteration raised accidentally inside a generator function will be interpreted as the end of the iteration by the loop construct driving the generator.

What if it's raised intentionally though? @gvanrossum needs to sit the fuck down, I'm glad he's taking his seat and backing off...so many terrible PEPs in the last couple versions.

@coleifer coleifer merged commit 18a337a into coleifer:master Jul 15, 2018
@coleifer
Copy link
Owner

Merged, thanks again for taking the time to investigate and fix.

@felixonmars felixonmars deleted the patch-1 branch July 15, 2018 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants