dbus-python variants

Pavel Strashkin pavel.strashkin at gmail.com
Thu Apr 28 08:47:00 PDT 2011


But it mustn't do it if it has introspection, isn't? As i know it's
trying to do guess signature only if introspection request was not
completed by any reason.

2011/4/28 Will Thompson <will.thompson at collabora.co.uk>:
> On 28/04/11 07:41, Lukas Hetzenecker wrote:
>> Hello,
>>
>> I want to transmit the following dict over dbus (using the dbus-python
>> bindings):
>>
>> {'name': 'test', 'id': 10} to a method with the signature a{sv}
>>
>> But i get the following error:
>> process 8413: Array or variant type requires that type string be written, but
>> end_dict_entry was written. The overall signature expected here was 'a{ss}'
>> and we are on byte 3 of that signature.
>>
>> So it doesn't like the different datatype of my dictionary values, but I
>> thought a "variant" can be of any type?
>>
>> The dbus-python tutorial states that a variant is "a container which may hold
>> any D-Bus type, including another variant".
>> So why does the automatic conversion to dbus types fail for the above
>> dictionary?
>
> Because dbus-python guesses the dictionary type by looking at the first
> key-value pair which is 's' and 's' in this case.
>
> You can use dbus.Dictionary({'name': 'test', 'id': 10}, signature='sv')
> to explicitly tell it what type the dictionary should have.
>
> --
> Will
> _______________________________________________
> dbus mailing list
> dbus at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dbus
>


More information about the dbus mailing list