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 759075 - pythonconsole not loading properly
pythonconsole not loading properly
Status: RESOLVED FIXED
Product: totem
Classification: Core
Component: Plugins
3.18.x
Other Linux
: Normal normal
: ---
Assigned To: General Totem maintainer(s)
General Totem maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2015-12-05 23:47 UTC by Laurent Bigonville
Modified: 2017-09-11 12:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
pythonconsole: Remove invalid __all__ variable (1.07 KB, patch)
2016-12-07 18:57 UTC, gnome.vrb
none Details | Review
pythonconsole: Use gi.require_version for python modules (1.69 KB, patch)
2016-12-07 19:11 UTC, gnome.vrb
accepted-commit_now Details | Review
pythonconsole: Import all classes to expose publicly (1.06 KB, patch)
2016-12-27 22:49 UTC, Philip Withnall
committed Details | Review
pythonconsole: Update gi.require_version for python modules (1.84 KB, patch)
2016-12-27 22:55 UTC, Philip Withnall
committed Details | Review

Description Laurent Bigonville 2015-12-05 23:47:18 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):
  • File "peas-python-internal.py", line 72 in call
  • File "peas-python-internal.py", line 131 in find_extension_type
AttributeError: 'module' object has no attribute 'OutFile'

(totem:26340): libpeas-WARNING **: Failed to run internal Python hook 'find_extension_type':
Traceback (most recent call last):
  • File "peas-python-internal.py", line 72 in call
  • File "peas-python-internal.py", line 131 in find_extension_type
AttributeError: 'module' object has no attribute 'OutFile'

(totem:26340): libpeas-WARNING **: Failed to run internal Python hook 'find_extension_type':
Traceback (most recent call last):
  • File "peas-python-internal.py", line 72 in call
  • File "peas-python-internal.py", line 131 in find_extension_type
AttributeError: 'module' object has no attribute 'OutFile'

Comment 1 Bastien Nocera 2015-12-06 13:51:50 UTC
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?
Comment 2 Laurent Bigonville 2015-12-07 09:57:16 UTC
I don't see any similar errors with GEdit or Rhythmbox
Comment 3 Bastien Nocera 2015-12-07 10:05:25 UTC
(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?
Comment 4 Laurent Bigonville 2015-12-07 10:18:56 UTC
I only have one version of libpeas, 1.16.0
Comment 5 gnome.vrb 2016-12-05 23:56:14 UTC
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):
  • File "/usr/lib/x86_64-linux-gnu/gedit/plugins/externaltools/outputpanel.py", line 189 in on_view_motion_notify_event
    self.update_cursor_style(view, int(event.x), int(event.y))
  • File "/usr/lib/x86_64-linux-gnu/gedit/plugins/externaltools/outputpanel.py", line 180 in update_cursor_style
    if self.get_link_at_location(view, x, y) is not None:
  • File "/usr/lib/x86_64-linux-gnu/gedit/plugins/externaltools/outputpanel.py", line 213 in get_link_at_location
    offset = iter_at_xy.get_offset()
AttributeError: '_ResultTuple' object has no attribute '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'
Comment 6 gnome.vrb 2016-12-07 18:57:04 UTC
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.
Comment 7 gnome.vrb 2016-12-07 18:58:21 UTC
Python console works with the above patch.
Comment 8 gnome.vrb 2016-12-07 19:11:34 UTC
Created attachment 341575 [details] [review]
pythonconsole: Use gi.require_version for python modules
Comment 9 Philip Withnall 2016-12-26 12:55:20 UTC
Review of attachment 341575 [details] [review]:

++
Comment 10 Philip Withnall 2016-12-27 22:49:07 UTC
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.
Comment 11 Philip Withnall 2016-12-27 22:50:59 UTC
(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.
Comment 12 Philip Withnall 2016-12-27 22:55:09 UTC
Created attachment 342514 [details] [review]
pythonconsole: Update gi.require_version for python modules
Comment 13 Philip Withnall 2016-12-27 22:56:02 UTC
(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.
Comment 14 gnome.vrb 2016-12-28 04:28:01 UTC
(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.
Comment 15 Bastien Nocera 2016-12-28 11:15:40 UTC
Philip, please commit whichever version you prefer. I doubt that many people use the Python console nowadays, even for developing Python plugins.
Comment 16 Philip Withnall 2017-09-11 12:25:39 UTC
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