GNOME Bugzilla – Bug 759075
pythonconsole not loading properly
Last modified: 2017-09-11 12:25:52 UTC
Hi, When trying to load the pythonconsole plugin, I get the following warning: (totem:26340): libpeas-WARNING **: Failed to run internal Python hook 'find_extension_type': Traceback (most recent call last):
+ Trace 235786
(totem:26340): libpeas-WARNING **: Failed to run internal Python hook 'find_extension_type': Traceback (most recent call last):
I'm guessing that the Python console is also broken in other apps that use libpeas for that feature, such as Rhythmbox and GEdit, right?
I don't see any similar errors with GEdit or Rhythmbox
(In reply to Laurent Bigonville from comment #2) > I don't see any similar errors with GEdit or Rhythmbox Which use the same versions of libpeas?
I only have one version of libpeas, 1.16.0
On libpeas: 1.20.0 1. Rhythmbox: I've never had any issues with Rhythmbox wrt the 'Python console'. Always works. 2. GEdit: This works. But not 100% fine. Get the following trace. Traceback (most recent call last):
+ Trace 236926
self.update_cursor_style(view, int(event.x), int(event.y))
if self.get_link_at_location(view, x, y) is not None:
offset = iter_at_xy.get_offset()
3. Totem: Doesn't work at all. Always get the following: (totem:14290): libpeas-WARNING **: Failed to run internal Python hook 'find_extension_type': Traceback (most recent call last): File "peas-python-internal.py", line 71, in call File "peas-python-internal.py", line 130, in find_extension_type AttributeError: module 'pythonconsole' has no attribute 'OutFile'
Created attachment 341574 [details] [review] pythonconsole: Remove invalid __all__ variable The "__all__" tuple exposes the public interface of the given python module. This should infact have been in console.py ( which defines PythonConsole and OutFile classes ). I don't see a strong reason for __all__ here, hence removing it.
Python console works with the above patch.
Created attachment 341575 [details] [review] pythonconsole: Use gi.require_version for python modules
Review of attachment 341575 [details] [review]: ++
Created attachment 342513 [details] [review] pythonconsole: Import all classes to expose publicly The PythonConsole and OutFile classes are exposed publicly by the console (so that the user can use them dynamically from the console); so both must be imported from their module first.
(In reply to vrishab from comment #6) > Created attachment 341574 [details] [review] [review] > pythonconsole: Remove invalid __all__ variable > > The "__all__" tuple exposes the public interface of the given python > module. This should infact have been in console.py ( which defines > PythonConsole and OutFile classes ). I don't see a strong reason for > __all__ here, hence removing it. This is not the right approach. The activation of the plugin was failing because __all__ was exposing OutFile without it being imported first. To keep the plugin code consistent with Rhythmbox and gedit, let’s keep the __all__ declaration. I’ve attached a patch which does this.
Created attachment 342514 [details] [review] pythonconsole: Update gi.require_version for python modules
(In reply to Philip Withnall from comment #12) > Created attachment 342514 [details] [review] [review] > pythonconsole: Update gi.require_version for python modules Updated/Rebased version of vrishab’s other patch.
(In reply to Philip Withnall from comment #10) > Created attachment 342513 [details] [review] [review] > pythonconsole: Import all classes to expose publicly > > The PythonConsole and OutFile classes are exposed publicly by the > console (so that the user can use them dynamically from the console); so > both must be imported from their module first. Sure. But, is it possible to keep __all__ in console.py ( consistent with gedit ), as below: https://git.gnome.org/browse/gedit/tree/plugins/pythonconsole/pythonconsole/console.py Rhythmbox merges console.py into the main plugin file.
Philip, please commit whichever version you prefer. I doubt that many people use the Python console nowadays, even for developing Python plugins.
Pushed my patch and the updated version of the gi.require_version patch to master. Attachment 342513 [details] pushed as c53f91a - pythonconsole: Import all classes to expose publicly Attachment 342514 [details] pushed as 382f18e - pythonconsole: Update gi.require_version for python modules