Send empty string lists with python
John (J5) Palmieri
johnp at redhat.com
Thu Jul 28 04:16:42 EST 2005
Ok, just had a look at this and there is a huge problem with respect to
empty arrays and dictionaries which I will post a seperate message
about. Basicly we check the first entry of a list to get the type of
the array we are sending since the information is needed when creating
the array on the bus. With an empty list there is no way for us to know
the element type in python land without introspection which is not
implemented yet. It is kinda anoying but I need to devise a way to
specify an element type and clients will have to use this when sending
empty lists i.e. they will have to special case their code and explictly
deal with types. It would most likely look like this:
array = dbus.Array([], dbus.String)
dict = dbus.Dict({}, key=dbus.String, value=dbus.Int32)
I could also throw an error if types are not specified when sending in
an empty list or dict.
However it would be nice for the protocol to support EmptyArray which
would cover both the array and dict types and in which case I could just
covert all empty arrays and dicts to this over the wire.
On Wed, 2005-07-27 at 18:30 +0200, Lennart Poettering wrote:
> Hi!
>
> If I try to call a remote DBUS method with an empty string array as
> argument with python-dbus I always get an IndexError on the client
> side:
>
> File "dbus_bindings.pyx", line 878, in dbus_bindings.MessageIter.append
> File "dbus_bindings.pyx", line 1033, in dbus_bindings.MessageIter.append_array
> IndexError: list index out of range
>
> If the string list is not empty everything works fine. How can I fix this?
>
> Lennart
>
> --
> Lennart Poettering; lennart [at] poettering [dot] de
> ICQ# 11060553; GPG 0x1A015CC4; http://0pointer.de/lennart/
--
More information about the dbus
mailing list