<p dir="auto"><strong>Migrated issue, originally created by Wichert Akkerman (<a href="https://github.com/wichert">@wichert</a>)</strong></p>
<p dir="auto">After upgrading from 0.9.4 to 0.9.5 or 0.9.6 I am suddenly seeing an error appear in my tests:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="src/lets_lynk/factory.py:51: in factory
&gt;       return query.first()
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/query.py:2334: in first
&gt;           ret = list(self[0:1])
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/query.py:2201: in __getitem__
&gt;               return list(res)
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/query.py:2404: in __iter__
&gt;           self.session._autoflush()
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/session.py:1188: in _autoflush
&gt;               self.flush()
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/session.py:1907: in flush
&gt;           self._flush(objects)
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/session.py:2025: in _flush
&gt;               transaction.rollback(_capture_exception=True)
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/util/langhelpers.py:57: in __exit__
&gt;           compat.reraise(exc_type, exc_value, exc_tb)
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/session.py:1989: in _flush
&gt;               flush_context.execute()
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/unitofwork.py:350: in execute
&gt;       postsort_actions = self._generate_actions()
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/unitofwork.py:324: in _generate_actions
&gt;               for rec in cycles
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/unitofwork.py:324: in &lt;genexpr&gt;
&gt;   for rec in cycles
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/unitofwork.py:541: in per_state_flush_actions
&gt;           dep.per_state_flush_actions(uow, states_for_prop, False)
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/dependency.py:166: in per_state_flush_actions
&gt;                                       else attributes.PASSIVE_NO_INITIALIZE)
E           TypeError: get_all_pending() takes exactly 3 arguments (4 given)"><pre class="notranslate"><code class="notranslate">src/lets_lynk/factory.py:51: in factory
&gt;       return query.first()
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/query.py:2334: in first
&gt;           ret = list(self[0:1])
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/query.py:2201: in __getitem__
&gt;               return list(res)
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/query.py:2404: in __iter__
&gt;           self.session._autoflush()
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/session.py:1188: in _autoflush
&gt;               self.flush()
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/session.py:1907: in flush
&gt;           self._flush(objects)
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/session.py:2025: in _flush
&gt;               transaction.rollback(_capture_exception=True)
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/util/langhelpers.py:57: in __exit__
&gt;           compat.reraise(exc_type, exc_value, exc_tb)
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/session.py:1989: in _flush
&gt;               flush_context.execute()
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/unitofwork.py:350: in execute
&gt;       postsort_actions = self._generate_actions()
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/unitofwork.py:324: in _generate_actions
&gt;               for rec in cycles
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/unitofwork.py:324: in &lt;genexpr&gt;
&gt;   for rec in cycles
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/unitofwork.py:541: in per_state_flush_actions
&gt;           dep.per_state_flush_actions(uow, states_for_prop, False)
../../Library/buildout/eggs/SQLAlchemy-0.9.5-py2.7-macosx-10.9-x86_64.egg/sqlalchemy/orm/dependency.py:166: in per_state_flush_actions
&gt;                                       else attributes.PASSIVE_NO_INITIALIZE)
E           TypeError: get_all_pending() takes exactly 3 arguments (4 given)
</code></pre></div>
<p dir="auto"><strong>Migrated issue, originally created by NotTheEvilOne (<a href="https://github.com/NotTheEvilOne">@NotTheEvilOne</a>)</strong></p>
<p dir="auto">Hi,</p>
<p dir="auto">the "autoflush" feature triggers an error in SQLAlchemy 0.9.6.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  File &quot;/opt/pas/src/dNG/pas/data/upnp/resources/mp_entry.py&quot;, line 588, in init_cds_id
    .first()
  File &quot;/usr/lib/python3.4/site-packages/sqlalchemy/orm/query.py&quot;, line 2334, in first
    ret = list(self[0:1])
  File &quot;/usr/lib/python3.4/site-packages/sqlalchemy/orm/query.py&quot;, line 2201, in __getitem__
    return list(res)
  File &quot;/usr/lib/python3.4/site-packages/sqlalchemy/orm/query.py&quot;, line 2404, in __iter__
    self.session._autoflush()
  File &quot;/usr/lib/python3.4/site-packages/sqlalchemy/orm/session.py&quot;, line 1188, in _autoflush
    self.flush()
  File &quot;/usr/lib/python3.4/site-packages/sqlalchemy/orm/session.py&quot;, line 1907, in flush
    self._flush(objects)
  File &quot;/usr/lib/python3.4/site-packages/sqlalchemy/orm/session.py&quot;, line 2025, in _flush
    transaction.rollback(_capture_exception=True)
  File &quot;/usr/lib/python3.4/site-packages/sqlalchemy/util/langhelpers.py&quot;, line 57, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File &quot;/usr/lib/python3.4/site-packages/sqlalchemy/util/compat.py&quot;, line 172, in reraise
    raise value
  File &quot;/usr/lib/python3.4/site-packages/sqlalchemy/orm/session.py&quot;, line 1989, in _flush
    flush_context.execute()
  File &quot;/usr/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py&quot;, line 350, in execute
    postsort_actions = self._generate_actions()
  File &quot;/usr/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py&quot;, line 324, in _generate_actions
    for rec in cycles
  File &quot;/usr/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py&quot;, line 324, in &lt;genexpr&gt;
    for rec in cycles
  File &quot;/usr/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py&quot;, line 541, in per_state_flush_actions
    dep.per_state_flush_actions(uow, states_for_prop, False)
  File &quot;/usr/lib/python3.4/site-packages/sqlalchemy/orm/dependency.py&quot;, line 166, in per_state_flush_actions
    else attributes.PASSIVE_NO_INITIALIZE)
TypeError: get_all_pending() takes 3 positional arguments but 4 were given"><pre class="notranslate"><code class="notranslate">  File "/opt/pas/src/dNG/pas/data/upnp/resources/mp_entry.py", line 588, in init_cds_id
    .first()
  File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2334, in first
    ret = list(self[0:1])
  File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2201, in __getitem__
    return list(res)
  File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2404, in __iter__
    self.session._autoflush()
  File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 1188, in _autoflush
    self.flush()
  File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 1907, in flush
    self._flush(objects)
  File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 2025, in _flush
    transaction.rollback(_capture_exception=True)
  File "/usr/lib/python3.4/site-packages/sqlalchemy/util/langhelpers.py", line 57, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 172, in reraise
    raise value
  File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 1989, in _flush
    flush_context.execute()
  File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 350, in execute
    postsort_actions = self._generate_actions()
  File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 324, in _generate_actions
    for rec in cycles
  File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 324, in &lt;genexpr&gt;
    for rec in cycles
  File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 541, in per_state_flush_actions
    dep.per_state_flush_actions(uow, states_for_prop, False)
  File "/usr/lib/python3.4/site-packages/sqlalchemy/orm/dependency.py", line 166, in per_state_flush_actions
    else attributes.PASSIVE_NO_INITIALIZE)
TypeError: get_all_pending() takes 3 positional arguments but 4 were given
</code></pre></div>
<p dir="auto">I think it's related to commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/sqlalchemy/sqlalchemy/commit/69dbcdd0ebf8de81643c038276fcc822a7b0bd0b/hovercard" href="https://github.com/sqlalchemy/sqlalchemy/commit/69dbcdd0ebf8de81643c038276fcc822a7b0bd0b"><tt>69dbcdd</tt></a> which in turn is related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="384630589" data-permission-text="Title is private" data-url="https://github.com/sqlalchemy/sqlalchemy/issues/3060" data-hovercard-type="issue" data-hovercard-url="/sqlalchemy/sqlalchemy/issues/3060/hovercard" href="https://github.com/sqlalchemy/sqlalchemy/issues/3060">#3060</a> as far as I understand.</p>
<p dir="auto">Best regards<br>
Tobias</p>