Issue 1:
Migrated issue, originally created by Robert Schütz (@dotlambda)

When I run the tests of SQLAlchemy's latest version using Python 3.7, I get

============================= test session starts ==============================
platform linux -- Python 3.7.0, pytest-3.6.2, py-1.5.3, pluggy-0.6.0 -- /nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/bin/python3.7m
cachedir: .pytest_cache
rootdir: /build/SQLAlchemy-1.2.8, inifile: setup.cfg
collecting ...
==================================== ERRORS ====================================
_____________ ERROR collecting test/aaa_profiling/test_memusage.py _____________
test/aaa_profiling/test_memusage.py:168: in <module>
class MemUsageTest(EnsureZeroed):
test/aaa_profiling/test_memusage.py:182: in MemUsageTest
@testing.requires.cextensions
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/testing/exclusions.py:96: in __call__
decorated = decorate(fn)
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
__________________ ERROR collecting test/base/test_events.py ___________________
test/base/test_events.py:1094: in <module>
class RemovalTest(fixtures.TestBase):
test/base/test_events.py:1247: in RemovalTest
@testing.requires.predictable_gc
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/testing/exclusions.py:96: in __call__
decorated = decorate(fn)
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
___________________ ERROR collecting test/base/test_utils.py ___________________
test/base/test_utils.py:135: in <module>
class WeakSequenceTest(fixtures.TestBase):
test/base/test_utils.py:136: in WeakSequenceTest
@testing.requires.predictable_gc
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/testing/exclusions.py:96: in __call__
decorated = decorate(fn)
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
________________ ERROR collecting test/dialect/test_firebird.py ________________
test/dialect/test_firebird.py:3: in <module>
from sqlalchemy.databases import firebird
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/databases/__init__.py:13: in <module>
from ..dialects.postgresql import base as postgresql
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/__init__.py:8: in <module>
from . import base, psycopg2, pg8000, pypostgresql, pygresql, \
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2153: in <module>
class PGDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2436: in PGDialect
def get_table_oid(self, connection, table_name, schema=None, **kw):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
_________________ ERROR collecting test/dialect/test_sqlite.py _________________
test/dialect/test_sqlite.py:28: in <module>
class TestTypes(fixtures.TestBase, AssertsExecutionResults):
test/dialect/test_sqlite.py:107: in TestTypes
@testing.provide_metadata
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
_________________ ERROR collecting test/dialect/test_suite.py __________________
test/dialect/test_suite.py:1: in <module>
from sqlalchemy.testing.suite import *
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/testing/suite/__init__.py:2: in <module>
from sqlalchemy.testing.suite.test_dialect import *
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/testing/suite/test_dialect.py:11: in <module>
class ExceptionTest(fixtures.TablesTest):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/testing/suite/test_dialect.py:29: in ExceptionTest
@requirements.duplicate_key_raises_integrity_error
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/testing/exclusions.py:96: in __call__
decorated = decorate(fn)
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
_________________ ERROR collecting test/dialect/test_sybase.py _________________
test/dialect/test_sybase.py:3: in <module>
from sqlalchemy.databases import sybase
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/databases/__init__.py:13: in <module>
from ..dialects.postgresql import base as postgresql
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/__init__.py:8: in <module>
from . import base, psycopg2, pg8000, pypostgresql, pygresql, \
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2153: in <module>
class PGDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2436: in PGDialect
def get_table_oid(self, connection, table_name, schema=None, **kw):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
_____________ ERROR collecting test/dialect/mssql/test_compiler.py _____________
test/dialect/mssql/test_compiler.py:5: in <module>
from sqlalchemy.dialects import mssql
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mssql/__init__.py:8: in <module>
from . import base, pyodbc, adodbapi, pymssql, zxjdbc, mxodbc # noqa
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mssql/base.py:1802: in <module>
class MSDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mssql/base.py:1982: in MSDialect
@reflection.cache
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
______________ ERROR collecting test/dialect/mssql/test_engine.py ______________
test/dialect/mssql/test_engine.py:5: in <module>
from sqlalchemy.dialects.mssql import pyodbc, pymssql, adodbapi
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mssql/__init__.py:8: in <module>
from . import base, pyodbc, adodbapi, pymssql, zxjdbc, mxodbc # noqa
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mssql/base.py:1802: in <module>
class MSDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mssql/base.py:1982: in MSDialect
@reflection.cache
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
______________ ERROR collecting test/dialect/mssql/test_query.py _______________
test/dialect/mssql/test_query.py:4: in <module>
from sqlalchemy.databases import mssql
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/databases/__init__.py:13: in <module>
from ..dialects.postgresql import base as postgresql
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/__init__.py:8: in <module>
from . import base, psycopg2, pg8000, pypostgresql, pygresql, \
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2153: in <module>
class PGDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2436: in PGDialect
def get_table_oid(self, connection, table_name, schema=None, **kw):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
____________ ERROR collecting test/dialect/mssql/test_reflection.py ____________
test/dialect/mssql/test_reflection.py:5: in <module>
from sqlalchemy.databases import mssql
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/databases/__init__.py:13: in <module>
from ..dialects.postgresql import base as postgresql
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/__init__.py:8: in <module>
from . import base, psycopg2, pg8000, pypostgresql, pygresql, \
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2153: in <module>
class PGDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2436: in PGDialect
def get_table_oid(self, connection, table_name, schema=None, **kw):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
______________ ERROR collecting test/dialect/mssql/test_types.py _______________
test/dialect/mssql/test_types.py:10: in <module>
from sqlalchemy.dialects.mssql import TIMESTAMP, ROWVERSION
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mssql/__init__.py:8: in <module>
from . import base, pyodbc, adodbapi, pymssql, zxjdbc, mxodbc # noqa
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mssql/base.py:1802: in <module>
class MSDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mssql/base.py:1982: in MSDialect
@reflection.cache
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
_____________ ERROR collecting test/dialect/mysql/test_compiler.py _____________
test/dialect/mysql/test_compiler.py:13: in <module>
from sqlalchemy.dialects.mysql import insert
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/__init__.py:8: in <module>
from . import base, mysqldb, oursql, \
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/base.py:1643: in <module>
class MySQLDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/base.py:1959: in MySQLDialect
@reflection.cache
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
_____________ ERROR collecting test/dialect/mysql/test_dialect.py ______________
test/dialect/mysql/test_dialect.py:9: in <module>
from ...engine import test_execute
<frozen importlib._bootstrap>:983: in _find_and_load
???
<frozen importlib._bootstrap>:967: in _find_and_load_unlocked
???
<frozen importlib._bootstrap>:668: in _load_unlocked
???
<frozen importlib._bootstrap>:638: in _load_backward_compatible
???
/nix/store/kc826j8kxs4kfhipjg99a3c9wdwm2a7v-python3.7-pytest-3.6.2/lib/python3.7/site-packages/_pytest/assertion/rewrite.py:216: in load_module
py.builtin.exec_(co, mod.__dict__)
test/engine/test_execute.py:20: in <module>
from sqlalchemy.dialects.oracle.zxjdbc import ReturningParam
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/__init__.py:8: in <module>
from . import base, cx_oracle, zxjdbc # noqa
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/base.py:1025: in <module>
class OracleDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/base.py:1219: in OracleDialect
resolve_synonyms=False, dblink='', **kw):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
___________ ERROR collecting test/dialect/mysql/test_on_duplicate.py ___________
test/dialect/mysql/test_on_duplicate.py:4: in <module>
from sqlalchemy.dialects.mysql import insert
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/__init__.py:8: in <module>
from . import base, mysqldb, oursql, \
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/base.py:1643: in <module>
class MySQLDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/base.py:1959: in MySQLDialect
@reflection.cache
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
______________ ERROR collecting test/dialect/mysql/test_query.py _______________
test/dialect/mysql/test_query.py:9: in <module>
class IdiosyncrasyTest(fixtures.TestBase):
test/dialect/mysql/test_query.py:13: in IdiosyncrasyTest
@testing.emits_warning()
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
____________ ERROR collecting test/dialect/mysql/test_reflection.py ____________
test/dialect/mysql/test_reflection.py:12: in <module>
from sqlalchemy.dialects.mysql import base as mysql
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/__init__.py:8: in <module>
from . import base, mysqldb, oursql, \
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/base.py:1643: in <module>
class MySQLDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/base.py:1959: in MySQLDialect
@reflection.cache
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
______________ ERROR collecting test/dialect/mysql/test_types.py _______________
test/dialect/mysql/test_types.py:8: in <module>
from sqlalchemy.dialects.mysql import base as mysql
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/__init__.py:8: in <module>
from . import base, mysqldb, oursql, \
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/base.py:1643: in <module>
class MySQLDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/base.py:1959: in MySQLDialect
@reflection.cache
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
____________ ERROR collecting test/dialect/oracle/test_compiler.py _____________
test/dialect/oracle/test_compiler.py:23: in <module>
from sqlalchemy.dialects.oracle import cx_oracle, base as oracle
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/__init__.py:8: in <module>
from . import base, cx_oracle, zxjdbc # noqa
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/base.py:1025: in <module>
class OracleDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/base.py:1219: in OracleDialect
resolve_synonyms=False, dblink='', **kw):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
_____________ ERROR collecting test/dialect/oracle/test_dialect.py _____________
test/dialect/oracle/test_dialect.py:22: in <module>
from sqlalchemy.dialects.oracle import cx_oracle, base as oracle
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/__init__.py:8: in <module>
from . import base, cx_oracle, zxjdbc # noqa
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/base.py:1025: in <module>
class OracleDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/base.py:1219: in OracleDialect
resolve_synonyms=False, dblink='', **kw):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
___________ ERROR collecting test/dialect/oracle/test_reflection.py ____________
test/dialect/oracle/test_reflection.py:16: in <module>
from sqlalchemy.dialects.oracle.base import NUMBER, BINARY_DOUBLE, \
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/__init__.py:8: in <module>
from . import base, cx_oracle, zxjdbc # noqa
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/base.py:1025: in <module>
class OracleDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/base.py:1219: in OracleDialect
resolve_synonyms=False, dblink='', **kw):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
______________ ERROR collecting test/dialect/oracle/test_types.py ______________
test/dialect/oracle/test_types.py:23: in <module>
from sqlalchemy.dialects.oracle import cx_oracle, base as oracle
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/__init__.py:8: in <module>
from . import base, cx_oracle, zxjdbc # noqa
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/base.py:1025: in <module>
class OracleDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/base.py:1219: in OracleDialect
resolve_synonyms=False, dblink='', **kw):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
__________ ERROR collecting test/dialect/postgresql/test_compiler.py ___________
test/dialect/postgresql/test_compiler.py:10: in <module>
from sqlalchemy.dialects.postgresql import ExcludeConstraint, array
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/__init__.py:8: in <module>
from . import base, psycopg2, pg8000, pypostgresql, pygresql, \
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2153: in <module>
class PGDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2436: in PGDialect
def get_table_oid(self, connection, table_name, schema=None, **kw):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
___________ ERROR collecting test/dialect/postgresql/test_dialect.py ___________
test/dialect/postgresql/test_dialect.py:14: in <module>
from sqlalchemy.dialects.postgresql import base as postgresql
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/__init__.py:8: in <module>
from . import base, psycopg2, pg8000, pypostgresql, pygresql, \
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2153: in <module>
class PGDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2436: in PGDialect
def get_table_oid(self, connection, table_name, schema=None, **kw):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
_________ ERROR collecting test/dialect/postgresql/test_on_conflict.py _________
test/dialect/postgresql/test_on_conflict.py:8: in <module>
from sqlalchemy.dialects.postgresql import insert
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/__init__.py:8: in <module>
from . import base, psycopg2, pg8000, pypostgresql, pygresql, \
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2153: in <module>
class PGDialect(default.DefaultDialect):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2436: in PGDialect
def get_table_oid(self, connection, table_name, schema=None, **kw):
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:128: in decorate
metadata.update(format_argspec_plus(spec, grouped=False))
/nix/store/qbjcg17f4605zx5gmkfg1z7i2j3zflwm-python3.7-SQLAlchemy-1.2.8/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py:374: in format_argspec_plus
args = inspect.formatargspec(*spec)
/nix/store/3hkchkmcz4kjldka2jpvfibpz12w847g-python3-3.7.0/lib/python3.7/inspect.py:1225: in formatargspec
stacklevel=2)
E DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
=========================== 25 error in 5.45 seconds ===========================

The same errors appear when running the tests from latest master.

Issue 2:
Migrated issue, originally created by Scott Milliken (@smilliken)

We've been getting occasional AttributeError exceptions raised from the sqlalchemy.ext.declarative.clsregistry._MultipleClassMarker.add_item method as it tries to access a __module__ attribute here: https://github.com/zzzeek/sqlalchemy/blob/28dd15081db4b7e978fa7a187c3aef1c0e4ad4e3/lib/sqlalchemy/ext/declarative/clsregistry.py#L106.

I haven't been able to identify the root cause or reliably reproduce the bug, but we are doing something fancy that's almost certainly related.

Using SQLAlchemy 0.9.6, Python 2.7.2, running inside Apache2.

Stacktrace:

Module ourmodule1:37 in __init__
<<
>> partition = aliased(get_partition_model(session, PartitionedTable))
Module ourmodule2:203 in get_partition_model
Module ourmodule2:190 in cons_model
Module sqlalchemy.ext.declarative.api:53 in __init__
<< def __init__(cls, classname, bases, dict_):
if '_decl_class_registry' not in cls.__dict__:
_as_declarative(cls, classname, cls.__dict__)
type.__init__(cls, classname, bases, dict_)
>> _as_declarative(cls, classname, cls.__dict__)
Module sqlalchemy.ext.declarative.base:148 in _as_declarative
<< table_args = None

clsregistry.add_class(classname, cls)
our_stuff = util.OrderedDict()
>> clsregistry.add_class(classname, cls)
Module sqlalchemy.ext.declarative.clsregistry:64 in add_class
<< for token in tokens:
module = module.get_module(token)
module.add_class(classname, cls)
>> module.add_class(classname, cls)
Module sqlalchemy.ext.declarative.clsregistry:160 in add_class
<< if name in self.contents:
existing = self.contents[name]
existing.add_item(cls)
else:
existing = self.contents[name] = \
>> existing.add_item(cls)
Module sqlalchemy.ext.declarative.clsregistry:105 in add_item
<< def add_item(self, item):
modules = set([cls().__module__ for cls in self.contents])
if item.__module__ in modules:
util.warn(
>> modules = set([cls().__module__ for cls in self.contents])
AttributeError: 'NoneType' object has no attribute '__module__'

The fanciness I mentioned is the get_partition_model function referenced in the stacktrace. The purpose of this function is to take the SQLAlchemy model for a PostgreSQL paritioned table (using table inheritance), and return a new SQLAlchemy model for the named partition. We cannot use SQLAlchemy's inheritance facilities because there's no discriminator column in the table partitions we can use. Here's the implementation of this function:

def get_partition_model(session, model, partition_id=None):
'''
Get a model specialized for the child partition identified by @partition_id.

Assumes partitions are named like '%(parent_table)s_%(partition_id)s'.

If @partition_id is None, then the partition with the latest lexical sort will be returned.
'''
def cons_model(partition_name):
classname = str('%s%s' % (model.__name__, partition_name.split('_')[-1]))
if classname in model._decl_class_registry:
return model._decl_class_registry[classname]
newtable = copy.copy(model.__table__)
newtable.name = partition_name
for col in newtable.columns:
col.table = newtable
return type(classname, (model,), {
'__table__': newtable,
'__tablename__': partition_name,
'__mapper_args__': {'concrete': True}
})
tablename = model.__table__.name
# NB: get_child_tables returns a list of partition tables using pg_class and pg_inherits
partitions = get_child_tables(session, tablename)
if not partitions:
return
if partition_id:
partition_name = '%s_%s' % (tablename, partition_id)
if partition_name not in partitions:
raise ValueError('No such partition %r for %r' % (partition_id, tablename))
else:
partition_name = max(partitions)
return cons_model(partition_name)

This code works approximately 100% of the time, but on rare occasions triggers the AttributeError mentioned. If I were to guess, I'd assume there's a race condition/thread safety issue (not neccessarily in SQLAlchemy).

Admittedly, this is a poor bug report since we're doing something fancy with dynamically created models, and I haven't given you any way to reproduce this. I thought I'd report it anyway in case it's obvious to you what's going on or if it invalidates some assumption in the code.