GNOME Bugzilla – Bug 625983
g_irepository_enumerate_versions should also include typelibs imported with g_irepository_require_private
Last modified: 2015-02-07 16:52:04 UTC
If one requires a private typelib using g_irepository_require_private(), he won't be able to import it later in python. The reason is that .enumerate_version doesn't enumerate private typelibs, but pygobject won't try to call repository.require if the namespace doesn't appear in enumerate_versions().
A possible fix would be for g_irepository_enumerate_versions() to include already loaded versions of a typelib. With the fact that g_irepository_require() will "work" (i.e. do nothing) for already loaded namespaces, this would have the nice effect of allowing one to do "from gi.repository import Private" after using the require_private() api from C code.
Would make sense to me for _enumerate to return loaded versions.
For anybody interested in doing what Walters said, it's a matter of augmenting what g_irepository_enumerate_versions returns with the contents of repository->priv->typelibs. http://git.gnome.org/browse/gobject-introspection/tree/girepository/girepository.c#n1174
Created attachment 168008 [details] [review] Include the loaded version in g_irepository_enumerate_versions() Logically speaking, the already loaded version of a namespace is part of the currently available versions, and can be forgotten if we only consider the versions available in GI_TYPELIB_PATH, as it could have been loaded using g_irepository_require_private(). As a side effect, it meant that bindings relying on enumerate_version() (like pygobject) were not able to require private versions through their classical requirement scheme. This patch fixes it by adding the loaded version to the unsorted list of available versions returned by g_irepository_enumerate_versions() This patch also uses g_list_prepend() instead of g_list_append() in that function.
Review of attachment 168008 [details] [review]: This looks good; can you also add a quick note to the function documentation? Maybe just change "list of versions" to "list of versions (either currently loaded or available)".
Created attachment 168012 [details] [review] Include the loaded version in g_irepository_enumerate_versions() Fix the documentation.
Attachment 168012 [details] pushed as 3ed944e - Include the loaded version in g_irepository_enumerate_versions()
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]