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 444366 - Nautilus doesn't load Python extensions
Nautilus doesn't load Python extensions
Status: RESOLVED FIXED
Product: nautilus-python
Classification: Other
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Johan (not receiving bugmail) Dahlin
Johan (not receiving bugmail) Dahlin
: 501212 505594 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-06-05 14:54 UTC by DoomHammerNG
Modified: 2008-01-11 14:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fixes amd64 builds against Python 2.5 (374 bytes, patch)
2007-11-30 00:41 UTC, Jonathan Rogers
none Details | Review
Improved patch for both Python 2.4 and 2.5 (1.83 KB, patch)
2007-11-30 09:14 UTC, Jonathan Rogers
none Details | Review

Description DoomHammerNG 2007-06-05 14:54:04 UTC
Please describe the problem:
After copying some example python extensions into ~/.nautilus/python-extensions Nautilus seems to load them, but they are useless - they don't provide any additional functionality. Is there a way to fix it somehow?

Steps to reproduce:


Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Jonathan Rogers 2007-09-19 03:47:36 UTC
I just tried some python nautilus extension examples and I'm seeing the same problem. Actually, I also saw the library loading bug in <URL:http://bugzilla.gnome.org/show_bug.cgi?id=327739> as well, though I worked around it by manually creating a symlink.

I am using GNOME nautilus 2.19.91 in Ubuntu Gutsy Gibbon. I copied the examples from Ubuntu's python-nautilus package to ~/.nautilus/python. I then ran a new instance of nautilus with "nautilus --no-desktop" and got the following in the terminal:
-----------------------------------------------------------------------
Initializing nautilus-open-terminal extension
Initializing nautilus-share extension
Initializing gnome-mount extension
seahorse nautilus module initialized
sys:1: GtkWarning: Refusing to add non-unique action 'submenu_file:\s\s\shome\sjrogers\s.gnome2\snautilus-scripts\sicons' to action group 'ScriptsGroup'
Nautilus-Share-Message: REFRESHING SHARES
Nautilus-Share-Message: ------------------------------------------
Nautilus-Share-Message: spawn arg "net"
Nautilus-Share-Message: spawn arg "usershare"
Nautilus-Share-Message: spawn arg "info"
Nautilus-Share-Message: end of spawn args; SPAWNING

Nautilus-Share-Message: returned from spawn: SUCCESS: 
Nautilus-Share-Message: exit code 255
Nautilus-Share-Message: ------------------------------------------
Nautilus-Share-Message: Called "net usershare info" but it failed: 'net usershare' returned error 255: net usershare: usershares are currently disabled
-----------------------------------------------------------------------

I expected to see messages about initializing the python modules in addition to the native C ones. After starting nautilus, I found a newly created .pyc file for each .py file, so I know the python interpreter read and compiled them. However, there are no effects from any of the plugins on the nautilus GUI and no messages in the terminal regarding any of them.
Comment 2 Jonathan Rogers 2007-09-19 17:22:04 UTC
I have experimented more with nautilus and nautilus-python. By setting the environment variable NAUTILUS_PYTHON_DEBUG to "misc", I persuaded nautilus-python to spit out a bunch of debug messages. It prints the message "nautilus-python:Loaded python modules" after loading each python extension. After all python extensions have been loaded, it prints "nautilus_module_list_types: entered" then "nautilus_module_shutdown: entered". So, apparently, nautilus-python shuts itself down immediately after loading all the extensions, rendering itself completely useless.

I compiled SVN trunk of nautilus-python, which is over a year old. Though it successfully builds, I get the following messages in the middle of the build:

----------------------------------------------------------------------------
Warning: generating old-style constructor for:nautilus_column_new
Warning: generating old-style constructor for:nautilus_menu_item_new
Warning: generating old-style constructor for:nautilus_property_page_new
Could not write function nautilus_file_info_list_copy: No ArgType for GList*
Could not write function nautilus_file_info_list_free: No ArgType for GList*
Warning: Constructor for NautilusColumn needs to be updated to new API
         See http://live.gnome.org/PyGTK_2fWhatsNew28#update-constructors
Warning: Constructor for NautilusMenuItem needs to be updated to new API
         See http://live.gnome.org/PyGTK_2fWhatsNew28#update-constructors
Warning: Constructor for NautilusPropertyPage needs to be updated to new API
         See http://live.gnome.org/PyGTK_2fWhatsNew28#update-constructors
----------------------------------------------------------------------------

Apparently, PyGTK, which nautilus-python depends on, had significant API changes in version 2.8. I tried to follow the instructions referred to by the Warning messages (the URL isn't quite right, so I had to search a bit). I succeeded in getting rid of Constructor warnings, but barely understood what I was doing, since I was editing Scheme code which apparently generates Gobject C code in order to interface with Python code. I did not succeed in getting rid of the errors about "No ArgType". Whether I really fixed any problems or not, nautilus still shuts down nautilus-python as soon as it initializes.

I suspect that nautilus-python is failing to initialize the nautilus objects properly, so appears useless to nautilus, which swiftly discards it. PyGTK has had major changes, but nautilus-python hasn't changed in quite a while, so it's rotted. I really hope someone can figure this out, since writing nautilus extensions in Python should be really easy and fun. I don't want to think about all that Gobject nastiness any more than I have to.
Comment 3 Jonathan Rogers 2007-11-30 00:39:19 UTC
I believe I've fixed this problem. It was due to a change in the Python/C API, not in PyGTK. Python 2.5 changed its C API to use Py_ssize_t in the PyDict_Next function instead of int. This causes Python extension classes to not be detected properly on amd64, though it still works on i386, probably because Py_ssize_t is the same size as int on i386, but they are different on amd64. So, nautilus-python probably needs to use different signatures depending on which version of Python it's building againts.
Comment 4 Jonathan Rogers 2007-11-30 00:41:05 UTC
Created attachment 99874 [details] [review]
Fixes amd64 builds against Python 2.5
Comment 5 Jonathan Rogers 2007-11-30 01:05:34 UTC
I should have checked earlier, but this issue is discussed in detail in PEP 353: <URL:http://www.python.org/dev/peps/pep-0353/>.
Comment 6 Jonathan Rogers 2007-11-30 09:14:50 UTC
Created attachment 99895 [details] [review]
Improved patch for both Python 2.4 and 2.5

Following <URL:http://www.python.org/dev/peps/pep-0353/>, this should allow proper compilation and execution on i386 and amd64 linked with Python 2.4 and 2.5 and hopefully other versions and architectures.
Comment 7 Johan (not receiving bugmail) Dahlin 2007-12-03 10:49:13 UTC
*** Bug 501212 has been marked as a duplicate of this bug. ***
Comment 8 DoomHammerNG 2007-12-18 13:41:56 UTC
I've downloaded and applied your patch. Python extensions seem to work, but now, unfortunately, Nautilus crashes and hangs often. What could be the source of the problem?
Comment 9 Jonathan Rogers 2007-12-18 13:49:20 UTC
It's really impossible to know what the problem is without more information, like what Nautilus or Python extension code is doing at the time. I have submitted another patch for freezes I triggered with specific Python extension code.
<URL:http://bugzilla.gnome.org/show_bug.cgi?id=500996>
Comment 10 Johan (not receiving bugmail) Dahlin 2007-12-26 09:50:55 UTC
*** Bug 505594 has been marked as a duplicate of this bug. ***
Comment 11 DoomHammerNG 2008-01-06 12:29:15 UTC
Seems OK. Will it hit the trunk?
Comment 12 Gilles Dartiguelongue 2008-01-11 13:36:14 UTC
Made it work for me too.
Comment 13 Johan (not receiving bugmail) Dahlin 2008-01-11 14:13:12 UTC
2008-01-11  Jonathan Rogers <jonner@teegra.net>

	reviewed by: Johan Dahlin

	* src/nautilus-python-object.c:
	* src/nautilus-python.c: (nautilus_python_load_file):
	* src/nautilus-python.h:
	Use Py_ssize_t instead of int, so nautilus-python works on Python 2.5
	fixes #444366