Skip to content

Commit e8bc512

Browse files
committed
glib async methods return list for single result
fixes altdesktop#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.
1 parent f97900e commit e8bc512

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

dbus_next/glib/proxy_object.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,14 @@ def call_notify(msg, err):
133133
except DBusError as e:
134134
err = e
135135

136-
callback(msg.body, err)
136+
if not out_len:
137+
body = None
138+
elif out_len == 1:
139+
body = msg.body[0]
140+
else:
141+
body = msg.body
142+
143+
callback(body, err)
137144

138145
self.bus.call(
139146
Message(destination=self.bus_name,
@@ -162,12 +169,7 @@ def callback(body, err):
162169
if call_error:
163170
raise call_error
164171

165-
if not out_len:
166-
return None
167-
elif out_len == 1:
168-
return call_body[0]
169-
else:
170-
return call_body
172+
return call_body
171173

172174
method_name = f'call_{BaseProxyInterface._to_snake_case(intr_method.name)}'
173175
method_name_sync = f'{method_name}_sync'

0 commit comments

Comments
 (0)