[Telepathy] Type Conversion Error in PyGI tp-glib
Mystilleef
mystilleef at gmail.com
Wed Jun 15 17:31:57 PDT 2011
On Tue, Jun 14, 2011 at 2:52 AM, Tomeu Vizoso <tomeu at tomeuvizoso.net> wrote:
> On Mon, Jun 13, 2011 at 16:04, Danielle Madeley
> <danielle.madeley at collabora.co.uk> wrote:
>> On Mon, 2011-06-13 at 15:23 +0200, Tomeu Vizoso wrote:
>>
>>> > I'm I doing something wrong? Or is this a bug?
>>>
>>> PyGObject is auto-converting your Python int into a GValue, but isn't
>>> choosing the type that the C side expects. What i think should be done
>>> in this case (other than moving tp-glib from dbus-glib to gdbus) is to
>>> give PyGObject a hint of what type should the GValue map to, something
>>> like:
>>>
>>> "keepalive-interval": GValue(60, GValue.UInt32),
>>>
>>> Unfortunately, I don't think that exists, but would be worth asking to
>>> the PyGObject community and checking if a ticket already exists in
>>> bugzilla.gnome.org.
>>
>> Tomeu is right, this is actually the bug. I was mistakenly confused with
>> dbus-python.
>>
>> Tomeu, out of interest would PyGObject handle this better if it was a
>> GVariant. Now that gjs has gained GVariant support, I think we should
>> start exposing GVariant-based APIs for gobject-introspection instead of
>> TpAsv-based ones.
>
> Yup, with variants, PyGObject doesn't try any more to guess the type
> that the C side wants, so the user needs to do:
>
> GLib.Variant('i', 42)
> GLib.Variant('u', 42)
>
> Regards,
>
> Tomeu
>
John P says telepathy-glib should use overrides to avoid this problem.
His comment is here. https://bugzilla.gnome.org/show_bug.cgi?id=652518#c1
The solution he provided in the comments also solves the problem for me.
from gi.repository import GObject
value = GObject.Value()
value.init(GObject.TYPE_UINT)
value.set_uint(60)
Then pass value as a guint parameter.
More information about the telepathy
mailing list