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
```

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy-alembic/8314dcfd-57c5-4848-b2eb-748711af8f80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to