From 90c676243f041f354835168b89f09d0c35bd3fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= Date: Mon, 10 Jan 2022 20:48:05 +0100 Subject: [PATCH] dbus: fix traceback on python-2.7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code which replaced python-decorator introduced python-2.7 incompatibility. The getfullargspec() from the inspect module is drop in replacement for the getargspec() and both return the named tuple. Thus the args member has to be extracted the same way in both cases (python 2/3). Signed-off-by: Jaroslav Škarvada --- tuned/exports/dbus_exporter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tuned/exports/dbus_exporter.py b/tuned/exports/dbus_exporter.py index 63440c9..2034e1e 100644 --- a/tuned/exports/dbus_exporter.py +++ b/tuned/exports/dbus_exporter.py @@ -18,7 +18,7 @@ try: from inspect import getfullargspec def getargspec(func): - return getfullargspec(func).args + return getfullargspec(func) except ImportError: # Python2 version, drop after support stops from inspect import getargspec @@ -75,7 +75,7 @@ class DBusExporter(interfaces.ExporterInterface): def _prepare_for_dbus(self, method, wrapper): source = """def {name}({args}): return wrapper({args}) - """.format(name=method.__name__, args=', '.join(getargspec(method.__func__))) + """.format(name=method.__name__, args=', '.join(getargspec(method.__func__).args)) code = compile(source, '' % len(self._dbus_methods), 'exec') # https://docs.python.org/3.9/library/inspect.html # co_consts - tuple of constants used in the bytecode