[sugar] [Re: PS] How byte_arrays=True *actually* works

Simon McVittie simon.mcvittie
Wed Jul 25 18:45:46 EDT 2007


(Sending to the Sugar list because this seems to be a common mistake.)

This change doesn't do what you think it does:

> diff --git a/NEWS b/NEWS
> index 211b63d..1c96fc4 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -1,3 +1,6 @@
> +* Return buddy properties as a byte array, not an array of bytes (dcbw)
> +* Don't list the owner twice in GetBuddies method (danw)
> +
>  Snapshot 650c323462
>  
>  * Don't send None over D-Bus when updating current activity (danw)
> diff --git a/src/buddy.py b/src/buddy.py
> index f93f2e1..e3d2dc7 100644
> --- a/src/buddy.py
> +++ b/src/buddy.py
> @@ -373,7 +373,8 @@ class Buddy(ExportedGObject):
>          return acts
>  
>      @dbus.service.method(_BUDDY_INTERFACE,
> -                        in_signature="", out_signature="a{sv}")
> +                        in_signature="", out_signature="a{sv}",
> +                        byte_arrays=True)
>      def GetProperties(self):
>          """Retrieve set of Buddy's properties
>  

In fact, it does nothing. The byte_arrays kwarg always affects conversion
between D-Bus and Python, never conversion between Python and D-Bus. On
the method decorator, that's the conversion of the arguments:
GetProperties() has no arguments, so there's nothing to convert and the
kwarg has no effect.

If you want to send a byte array in a variant, you have to return either a
dbus.ByteArray or a dbus.Array(signature='y').

The same holds for utf8_strings and UTF8String.

	Simon



More information about the Sugar-devel mailing list