diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sqlalchemy/event/attr.py | 9 | ||||
-rw-r--r-- | lib/sqlalchemy/util/langhelpers.py | 4 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/sqlalchemy/event/attr.py b/lib/sqlalchemy/event/attr.py index 690ebce08..f0fff5ca4 100644 --- a/lib/sqlalchemy/event/attr.py +++ b/lib/sqlalchemy/event/attr.py @@ -62,10 +62,15 @@ class _DispatchDescriptor(RefCollection): self._empty_listeners = weakref.WeakKeyDictionary() def _adjust_fn_spec(self, fn, named): - argspec = util.get_callable_argspec(fn, no_self=True) if named: fn = self._wrap_fn_for_kw(fn) - fn = legacy._wrap_fn_for_legacy(self, fn, argspec) + if self.legacy_signatures: + try: + argspec = util.get_callable_argspec(fn, no_self=True) + except ValueError: + pass + else: + fn = legacy._wrap_fn_for_legacy(self, fn, argspec) return fn def _wrap_fn_for_kw(self, fn): diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index 7e261e38f..105b64c6b 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -268,7 +268,9 @@ def get_callable_argspec(fn, no_self=False): return compat.ArgSpec(spec.args[1:], spec.varargs, spec.keywords, spec.defaults) elif hasattr(fn, '__func__'): return compat.inspect_getargspec(fn.__func__) - elif hasattr(fn, '__call__'): + elif hasattr(fn, '__call__') and \ + not hasattr(fn.__call__, '__call__'): # functools.partial does this; + # not much we can do return get_callable_argspec(fn.__call__) else: raise ValueError("Can't inspect function: %s" % fn) |