GNOME Bugzilla – Bug 687047
gedit external plugin broken with current master
Last modified: 2012-11-03 10:48:14 UTC
It looks like latest changes broke gedit's external tools plugin: [paolo@murdock ~]$ gedit Gtk-Message: Failed to load module "pk-gtk-module" Gtk-Message: Failed to load module "canberra-gtk-module" /opt/gnome/lib64/gedit/plugins/externaltools/outputpanel.py:171: PyGIDeprecationWarning: idle_add is deprecated; use GLib.idle_add instead GObject.idle_add(self.scroll_to_end) /opt/gnome/lib64/gedit/plugins/externaltools/capture.py:105: PyGIDeprecationWarning: io_add_watch is deprecated; use GLib.io_add_watch instead self.on_output) /opt/gnome/lib64/python3.3/site-packages/gi/overrides/GLib.py:610: PyGIDeprecationWarning: Calling io_add_watch without priority as second argument is deprecated PyGIDeprecationWarning) Traceback (most recent call last):
+ Trace 231093
run_external_tool(window, panel, node)
capture.execute()
self.on_output)
return fn(*args, **kwargs)
assert isinstance(channel, GLib.IOChannel) AssertionError
Argh, sorry about that! I can reproduce.
I fixed this part in: http://git.gnome.org/browse/pygobject/commit/?id=0f94a0a4ebd2bbfd06d8f9a2bb2b17dabf7678ef However, now I get the following: /usr/lib/gedit/plugins/externaltools/capture.py:219: PyGIDeprecationWarning: idle_add is deprecated; use GLib.idle_add instead GObject.idle_add(self.emit, 'end-execute', error_code) TypeError: 1 parameters needed for signal end-execute; 0 given TypeError: 1 parameters needed for signal end-execute; 0 given [...] I'll look into that ASAP, but I'm at UDS this week, so please feel free to beat me to it.
Created attachment 227687 [details] [review] Fix IOChannel unittests for python 2.7 These are changes to get unittests working again: - Use __future__ unicode_literals to minimize difference between python 2.7 and 3. Comparisons encode arguments as 'UTF-8' for testing readline operations. - Add backwards compatible "next" to support the python 2.7 iteration. - Change isinstance(channel, file) to hasattr(channel, 'fileno') to support all python versions (and duck typing). Also, I think it would be nice to continue supporting python io objects in place of IOChannels instead of deprecating this. It is very useful for adapting things like pythons multiprocessing module into a glib/gtk main loop.
The problem seems to be the original: idle_add, timeout_add, and io_add_watch functions supported a variable number of additional arguments to pass to the callback (not just a single user_data). priority could then be specified as an additional keyword arg. So the overridden prototypes need to follow the form: def idle_add(callback, *args, **kwargs): # Check within kwargs for priority # Use all of args as closure arguments but as a single user_data for overridden method.
Created attachment 227702 [details] [review] Fix IOChannel unittests for python 2.7 The encode calls ended up not being needed.
Created attachment 227703 [details] [review] Fix GLib override incompatibilities with static API Change idle_add, timeout_add, timeout_add_seconds, and io_add_watch to accept *args and **kwargs as arguments to callback functions instead of a single user_data arg. This also removes priority as an argument to the overridden methods and is instead pulled in through **kwargs (as in the original static bindings). This should at least get things working again. Another pass can be done to add the priority arg back with deprecations, but it will take a lot more argument mangling to make that happen. Verified the external tools plugin works again within gedit. A review would be nice but if no one is around I will push these patches as the current head is somewhat broken.
The following fixes have been pushed: 80db2a5 Fix GLib override incompatibilities with old static API 9c6399b Fix IOChannel unittests for python 2.7
Created attachment 227706 [details] [review] Fix GLib override incompatibilities with old static API Change idle_add, timeout_add, timeout_add_seconds, and io_add_watch to accept *args and **kwargs as arguments to the callback functions instead of only accepting a single user_data arg. This ensures the new overridden introspection methods are backwards compatible with the static versions they replaced.
Created attachment 227707 [details] [review] Fix IOChannel unittests for python 2.7 Use __future__ unicode_literals to minimize difference between python 2.7 and 3. Comparisons need to encode arguments as 'UTF-8' for testing readline operations. Add backwards compatible "next" to support the python 2.7 iteration. Change isinstance(channel, file) to hasattr(channel, 'fileno') to support all python versions (and duck typing).
Thanks Simon for the fast fix! I'll clean up the patch in a few days when I travle back home; I want to factor out the mangling of the callback and bring back the real GLib API.
For the record, I now fixed this more properly in git.