GNOME Bugzilla – Bug 642305
lazy-loading of typelibs is too late in some cases
Last modified: 2011-02-23 08:45:04 UTC
Specifically when trying to create a class wrapper from pygobject_new_full, which uses pygi_type_import_by_g_type(), as the typelib hasn't been loaded yet, it will fail to return the info. This is the case when a function returns an object of a class which is defined in a typelib that hasn't been loaded yet.
We need to go back to load the typelibs when the import statement is executed. It means that the current way to specify the typelib version that should be loaded won't work. This is the API change that has been agreed: import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk
Created attachment 180975 [details] [review] Load typelibs at import time, add gi.require_version() Suggestions about how to test this are welcome
Created attachment 180997 [details] [review] Load typelibs at import time, add gi.require_version() also adds Repository.get_loaded_namespaces() Add some more sanity checks
Comment on attachment 180997 [details] [review] Load typelibs at import time, add gi.require_version() Looks good, tests pass, demos run...commit to master and pygobject-2-28 branches
Pushed as http://git.gnome.org/browse/pygobject/commit/?id=76758efb6579752237a0dc4d56cf9518de6c6e55
remember to push to the pygobject-2-28 branch too. I just did it for this patch
Reopening - there is an issue with function overrides I just noticed. Gtk.main_quit does not get overridden so we get these errors when doing window.connect('destroy', Gtk.main_quit): Traceback (most recent call last):
+ Trace 226062
return info.invoke(*args)
Created attachment 181634 [details] [review] [gi] Don't force loading of DynamicModule until set in sys.modules This fixes Tomeu's previous commit, which removed lazy loading. Forcing the loading of a module before it is installed in sys.modules prevents some overrides from being registered (namely Gtk.main_quit).
Pushed, thanks!