GNOME Bugzilla – Bug 652518
Wrong GValue Type Conversion in PyGI - PyGObject
Last modified: 2011-06-17 16:14:29 UTC
An API in PyGI telepathy-glib expects a guint32 value. Unfortunately, PyGObject converts the value into a guint which causes an error. Here's the specific error I'm getting. ============================================================ Traceback (most recent call last):
+ Trace 227470
account = am.create_account_finish(result)
return info.invoke(*args)
============================================================ Tomeu Vizoso on the Telepathy mailing list suggests PyGObject expose an API that helps with type conversion. Something like this. uint32value = GValue(60, GValue.UInt32) Does such an API already exist? Is there anything telepathy- glib can do to avoid this problem? Also is there anything I can do to work around the problem as a PyGI user? Telepathy mailinglist discussion on the problem: http://lists.freedesktop.org/archives/telepathy/2011-June/005592.html
Yes, GValues suck for dynamic bindings because in most cases applications are expecting a specific type but GValues give no indication of what type since they are containers that can hold any type. In C it becomes a contract between the API and the programmer, e.g. they have to know what type by reading the documentation. In Python we want to hide that from the user but we do expose an API for specifying GValue types. It should only be used in overrides so I would implore Telepathy devs to ship overrides and not expose this behaviour to the user: from gi.repository import GObject value = GObject.Value() value.init(GObject.TYPE_UNIT32) value.set_uint(x)
Thanks for the suggestion. I don't have GObject.TYPE_UNIT32 though. Is that in newer version of PyGObject. Where are those constants stored in older versions?
oh, that is just a GObject.TYPE_UINT, 32 is implied. The issue you were having was that the interface encoded a signed integer.
Thanks John, that fixed my problem. I'm guessing this is not a bug in PyGObject then and can be closed.