我遇到了一个非常奇怪的错误,很难重现:AttributeError: 'list' object has no attribute '_sa_adapter'
. 它似乎来自一对多的关系,但一切看起来都很好,我不能简单地重现这个错误。如果我单独运行测试套件,就没有错误,它只会在整个测试运行时发生。也许它来自没有正确清洁的东西......
这是完整的堆栈:
Traceback (most recent call last):
File "/Users/ca/[REDACTED].py", line 79, in setUp
self.client.save()
File "/Users/ca/[REDACTED].py", line 370, in save
Session.add(self)
File "/Users/ca/.pythonbrew/venvs/Python-2.7.3/api/lib/python2.7/site-packages/SQLAlchemy-0.7.5-py2.7-macosx-10.7-x86_64.egg/sqlalchemy/orm/scoping.py", line 113, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "/Users/ca/.pythonbrew/venvs/Python-2.7.3/api/lib/python2.7/site-packages/SQLAlchemy-0.7.5-py2.7-macosx-10.7-x86_64.egg/sqlalchemy/orm/session.py", line 1223, in add
self._save_or_update_state(state)
File "/Users/ca/.pythonbrew/venvs/Python-2.7.3/api/lib/python2.7/site-packages/SQLAlchemy-0.7.5-py2.7-macosx-10.7-x86_64.egg/sqlalchemy/orm/session.py", line 1238, in _save_or_update_state
halt_on=self._contains_state):
File "/Users/ca/.pythonbrew/venvs/Python-2.7.3/api/lib/python2.7/site-packages/SQLAlchemy-0.7.5-py2.7-macosx-10.7-x86_64.egg/sqlalchemy/orm/mapper.py", line 1814, in cascade_iterator
parent_dict, visited_states, halt_on))
File "/Users/ca/.pythonbrew/venvs/Python-2.7.3/api/lib/python2.7/site-packages/SQLAlchemy-0.7.5-py2.7-macosx-10.7-x86_64.egg/sqlalchemy/orm/properties.py", line 817, in cascade_iterator
get_all_pending(state, dict_)
File "/Users/ca/.pythonbrew/venvs/Python-2.7.3/api/lib/python2.7/site-packages/SQLAlchemy-0.7.5-py2.7-macosx-10.7-x86_64.egg/sqlalchemy/orm/attributes.py", line 775, in get_all_pending
current = getattr(current, '_sa_adapter')
AttributeError: 'list' object has no attribute '_sa_adapter'
你知道它可能来自哪里吗?
谢谢,
chx