core: handle callbacks that are not functions on Python 3.3

* Fix inspect.getargspec issue for non functions callbacks by creating
  an empty ArgSpec. There for we ignore all kwargs parameters.

Signed-off-by: Mathis FELARDOS <mathis.felardos@gmail.com>
This commit is contained in:
Mathis FELARDOS 2016-03-23 10:14:14 +01:00
parent d15b3173f1
commit 98e8a1cc04

View File

@ -90,9 +90,14 @@ class Module(SettingsBase):
wrapped_cb = getattr(cb, "__wrapped__", None)
if wrapped_cb:
locals()["self"] = self # Add self to the local stack frame
args_spec = inspect.getargspec(wrapped_cb)
tmp_cb = wrapped_cb
else:
args_spec = inspect.getargspec(cb)
tmp_cb = cb
try:
args_spec = inspect.getargspec(tmp_cb)
except Exception:
args_spec = inspect.ArgSpec([], None, None, None)
# Remove all variables present in kwargs that are not used in the
# callback, except if there is a keyword argument.