From 98e8a1cc048fda88b800663a60229a57852432db Mon Sep 17 00:00:00 2001 From: Mathis FELARDOS Date: Wed, 23 Mar 2016 10:14:14 +0100 Subject: [PATCH] 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 --- i3pystatus/core/modules.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/i3pystatus/core/modules.py b/i3pystatus/core/modules.py index 1461d5b..d32a491 100644 --- a/i3pystatus/core/modules.py +++ b/i3pystatus/core/modules.py @@ -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.