After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 642305 - lazy-loading of typelibs is too late in some cases
lazy-loading of typelibs is too late in some cases
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks: 642922
 
 
Reported: 2011-02-14 17:19 UTC by Tomeu Vizoso
Modified: 2011-02-23 08:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Load typelibs at import time, add gi.require_version() (3.84 KB, patch)
2011-02-16 10:54 UTC, Tomeu Vizoso
none Details | Review
Load typelibs at import time, add gi.require_version() (6.28 KB, patch)
2011-02-16 14:00 UTC, Tomeu Vizoso
committed Details | Review
[gi] Don't force loading of DynamicModule until set in sys.modules (1.07 KB, patch)
2011-02-22 20:40 UTC, Laszlo Pandy
committed Details | Review

Description Tomeu Vizoso 2011-02-14 17:19: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.
Comment 1 Tomeu Vizoso 2011-02-15 14:46:14 UTC
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
Comment 2 Tomeu Vizoso 2011-02-16 10:54:07 UTC
Created attachment 180975 [details] [review]
Load typelibs at import time, add gi.require_version()

Suggestions about how to test this are welcome
Comment 3 Tomeu Vizoso 2011-02-16 14:00:34 UTC
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 4 johnp 2011-02-18 23:36:34 UTC
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
Comment 6 johnp 2011-02-22 19:06:29 UTC
remember to push to the pygobject-2-28 branch too.  I just did it for this patch
Comment 7 johnp 2011-02-22 19:59:50 UTC
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):
  • File "/home/johnp/devel/gnome/install/lib64/python2.7/site-packages/gi/types.py", line 44 in function
    return info.invoke(*args)
TypeError: main_quit() takes exactly 0 argument(s) (1 given)

Comment 8 Laszlo Pandy 2011-02-22 20:40:12 UTC
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).
Comment 9 Tomeu Vizoso 2011-02-23 08:44:50 UTC
Pushed, thanks!