[Bug 423175] [NEW] Sqlalchemy debug callback error
Ivo Timmermans
ivo at lychnis.net
Wed Sep 2 13:22:34 UTC 2009
Public bug reported:
Line 122 of orm/strategies.py defines a logger function that is passed
to other places in the code, but it fails later on if the mapper object
is used. This is caused by the logfn argument to debug_callable, which
is passed three (+keyword) arguments instead of the two (+keyword)
arguments that it accepts. My code fails with:
File "/usr/lib/pymodules/python2.6/sqlalchemy/orm/attributes.py", line 158, in __get__
return self.impl.get(instance_state(instance), instance_dict(instance))
File "/usr/lib/pymodules/python2.6/sqlalchemy/orm/attributes.py", line 374, in get
value = callable_()
File "/usr/lib/pymodules/python2.6/sqlalchemy/orm/state.py", line 185, in __call__
attr.impl.key in unmodified
File "/usr/lib/pymodules/python2.6/sqlalchemy/orm/mapper.py", line 1841, in _load_scalar_attributes
result = session.query(mapper)._get(identity_key, refresh_state=state, only_load_props=attribute_names)
File "/usr/lib/pymodules/python2.6/sqlalchemy/orm/query.py", line 1431, in _get
return q.all()[0]
File "/usr/lib/pymodules/python2.6/sqlalchemy/orm/query.py", line 1198, in all
return list(self)
File "/usr/lib/pymodules/python2.6/sqlalchemy/orm/query.py", line 1353, in instances
rows = [process[0](context, row) for row in fetch]
File "/usr/lib/pymodules/python2.6/sqlalchemy/orm/query.py", line 1955, in main
return _instance(row, None)
File "/usr/lib/pymodules/python2.6/sqlalchemy/orm/mapper.py", line 1692, in _instance
populate_state(state, dict_, row, isnew, only_load_props)
File "/usr/lib/pymodules/python2.6/sqlalchemy/orm/mapper.py", line 1577, in populate_state
populator(state, dict_, row, isnew=isnew, **flags)
File "/usr/lib/pymodules/python2.6/sqlalchemy/orm/interfaces.py", line 890, in call
logger.debug(logfn(*args, **kwargs))
TypeError: <lambda>() takes exactly 2 non-keyword arguments (3 given)
I think the lambda has to accept a second argument:
--- strategies.py-distributed 2009-09-02 15:19:46.000000000 +0200
+++ strategies.py-fixed 2009-09-02 15:19:53.000000000 +0200
@@ -121,7 +121,7 @@
if self._should_log_debug:
new_execute = self.debug_callable(new_execute, self.logger,
"%s returning active column fetcher" % self,
- lambda state, row, **flags: "%s populating %s" % (self, mapperutil.state_attribute_str(state, key))
+ lambda state, dict_, row, **flags: "%s populating %s" % (self, mapperutil.state_attribute_str(state, key))
)
return (new_execute, None)
else:
I can't give an example of failing code, because I don't know how to get the mapper to call this debug_callable outside my application.
ProblemType: Bug
Architecture: amd64
Date: Wed Sep 2 15:13:11 2009
DistroRelease: Ubuntu 9.10
Package: python-sqlalchemy 0.5.5-1 [modified: usr/share/pyshared/sqlalchemy/orm/mapper.py]
PackageArchitecture: all
ProcEnviron:
SHELL=/bin/zsh
PATH=(custom, user)
LANG=nl_NL.UTF-8
LANGUAGE=nl_NL.UTF-8
ProcVersionSignature: Ubuntu 2.6.31-9.29-generic
SourcePackage: sqlalchemy
Uname: Linux 2.6.31-9-generic x86_64
** Affects: sqlalchemy (Ubuntu)
Importance: Undecided
Status: New
** Tags: amd64 apport-bug
--
Sqlalchemy debug callback error
https://bugs.launchpad.net/bugs/423175
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
--
ubuntu-bugs mailing list
ubuntu-bugs at lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
More information about the universe-bugs
mailing list