Indeed, I was using version 1.0.9 and didn't realise that this wasn't an issue with alembic. Thanks for the quick response.
On Friday, 28 June 2019 22:30:49 UTC+2, Mike Bayer wrote: > > > > On Fri, Jun 28, 2019, at 4:01 PM, gbr wrote: > > I've upgraded my application to Python 3.7 and to the latest version of > Alembic which triggers an exception when `context.get_current_revision()` > is called. > > ``` > File "app.py", line 395, in check_database_version > current_rev = context.get_current_revision() > File > "~/env-py3.7/lib/python3.7/site-packages/alembic/runtime/migration.py", > line 239, in get_current_revision > heads = self.get_current_heads() > File > "~/env-py3.7/lib/python3.7/site-packages/alembic/runtime/migration.py", > line 289, in get_current_heads > row[0] for row in self.connection.execute(self._version.select()) > File > "~/env-py3.7/lib/python3.7/site-packages/alembic/runtime/migration.py", > line 289, in <genexpr> > row[0] for row in self.connection.execute(self._version.select()) > RuntimeError: generator raised StopIteration > ``` > > I think this is due to PEP 479. > > PEP 479 <https://www.python.org/dev/peps/pep-0479> is enabled for all > code in Python 3.7, meaning that StopIteration > <https://docs.python.org/3/library/exceptions.html#StopIteration> > exceptions raised directly or indirectly in coroutines and generators are > transformed into RuntimeError > <https://docs.python.org/3/library/exceptions.html#RuntimeError> > exceptions. (Contributed by Yury Selivanov in bpo-32670 > <https://bugs.python.org/issue32670>.) > > > I changed `ResultProxy.__iter__()` to: > > > > > ``` > class ResultProxy > ... > def __iter__(self): > while True: > row = self.fetchone() > if row is None: > # raise StopIteration > return > else: > yield row > > > The source code for ResultProxy is in SQLAlchemy, not Alembic. The > "StopIteration" you seem to be referring to was removed four years ago in > https://github.com/sqlalchemy/sqlalchemy/commit/6ab120558078bdcbfbe06d2ca55bd7a0d417bbb4 > > , so I would suggest upgrading to a modern version of SQLAlchemy. > > > ``` > > which seems to resolve the problem. Is this a problem with Alembic and an > incompatibility with Python 3.7, and is this expected to be fixed soon? > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy-alembic" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy-alembic+unsubscr...@googlegroups.com <javascript:>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy-alembic/8314dcfd-57c5-4848-b2eb-748711af8f80%40googlegroups.com > > <https://groups.google.com/d/msgid/sqlalchemy-alembic/8314dcfd-57c5-4848-b2eb-748711af8f80%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy-alembic/be11f4c4-2dea-4cdf-b250-fc96100e36b1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.