From e8bc512e7d44fccf4d0a809631207cfa49192421 Mon Sep 17 00:00:00 2001 From: Micah Nordland Date: Wed, 22 Dec 2021 00:43:36 -0500 Subject: [PATCH] glib async methods return list for single result fixes #108 The async method calls on the glib.ProxyInterface class lacked the ability to unpack a single result while the sync version did do that. This commit moves unpacking code to the async version so both will behave correctly. --- dbus_next/glib/proxy_object.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/dbus_next/glib/proxy_object.py b/dbus_next/glib/proxy_object.py index b5887ba..ee0600b 100644 --- a/dbus_next/glib/proxy_object.py +++ b/dbus_next/glib/proxy_object.py @@ -133,7 +133,14 @@ def call_notify(msg, err): except DBusError as e: err = e - callback(msg.body, err) + if not out_len: + body = None + elif out_len == 1: + body = msg.body[0] + else: + body = msg.body + + callback(body, err) self.bus.call( Message(destination=self.bus_name, @@ -162,12 +169,7 @@ def callback(body, err): if call_error: raise call_error - if not out_len: - return None - elif out_len == 1: - return call_body[0] - else: - return call_body + return call_body method_name = f'call_{BaseProxyInterface._to_snake_case(intr_method.name)}' method_name_sync = f'{method_name}_sync'