Wed 19 Nov 2014 06:20:44 PM UTC, comment #8:
I can reproduce the this problem on my Fedora 21 based system, using
- WeeChat 1.0.1, ncurses client
- PyGTK version 2.24.0
- Python 2.7.8
- "anotify.py" script, version 1.0.1
when reloading "anotify" (as described in comment #6).
@SebastiƩn: Which version of lnotify have you been using? It seems that lnotify has changed and does not use pynotify anymore, at least not since version 0.2.0.
This problem is related to the use of Python sub-interpreters, which seem to have trouble with native modules like gtk._gtk that modify the module directory as part of their initialization code:
https://docs.python.org/2/c-api/init.html#bugs-and-caveats
It seems like dynamic objects (gtk.so) are loaded only once per _process, which is why the initialization code is not re-run the second time the import is triggered (by importing pynotify, which imports gtk, which imports gtk), and thus the module directory of the new interpreter state is not populated with the "gdk" module. Comment #6 was on the right track suspecting the "weird magic" that is involved in loading "gdk", and that there is at least _something on the WeeChat side (using sub-interpreters within a single process) that triggers this bug (gtk being unable to find the "virtual" gdk module).
This bug will also be triggered if two more more different Python scripts are are importing the "gtk" module -- only the first one will succeed.
However, if anything, it can be considered a bug in Python, or in the implementation details of PyGTK (not allowing for proper reloading), but it is definitely not a bug in WeeChat. I am not sure if there is a workaround that does not involve chancing either Python or PyGTK.
|
Fri 28 Mar 2014 05:55:55 AM UTC, comment #7:
The bug was not waiting, it was closed. So I reopen it.
I just tried to install lnotify.py, remove it, and reinstall it again, I have no such error with gdk.
I'm using Debian Sid, Python 2.7.6, WeeChat 0.4.4-dev (same result with 0.4.3).
I tried on 2 machines: one with X, the other without X.
In both cases, I never see the error you have, so I'm not able to reproduce the problem.
|
Fri 28 Mar 2014 03:11:44 AM UTC, comment #6:
I realize this bug has been sitting around for three years...but I'm pretty sure this is a bug in weechat. It seems quite reproducible. First, we start with python on the command line, just to demonstrate that things are working in general:
Now, we load the lnotify.py script in weechat, and it works just fine:
We remove the script:
And now try to load it again:
KABOOM!
This happens every time. Fedora 19, python 2.7.5, weechat 0.4.3.
Now, the problematic "gdk" module is loaded through some sort of weird magic, so maybe weechat is doing something w/r/t dynamic library symbol lookups that is making this fragile?
|
Tue 21 Sep 2010 08:50:45 AM UTC, comment #5:
I'm using Debian.
(for more discussion about bugs, please join #weechat on irc.freenode.net, it's faster than replying in bug)
|
Tue 21 Sep 2010 08:44:58 AM UTC, comment #4:
OK, sorry. Then I'll try another distribution first. What distribution are you using?
|
Tue 21 Sep 2010 08:43:18 AM UTC, comment #3:
I read your comment.
But I still think it's not a WeeChat bug, the error displayed is from python, not from WeeChat.
I made a test script with "import gtk", like you, and I have no error displayed in WeeChat.
|
Tue 21 Sep 2010 08:40:49 AM UTC, comment #2:
I think you didn't read my comment:
When I use import gtk in a standalone script or in ipython it doesn't throw an error.
So I made a testscript with the gtk import, ran it as python testscript.py => no error
Started the python shell: ipython
import gtk<CR>: no error
A very simple script in Weechat (with the import and a weechat.register): error
|
Tue 21 Sep 2010 06:01:48 AM UTC, comment #1:
I think it's not a WeeChat bug. WeeChat just displays error from python, so if you have this error, it's a python problem on your box.
Try to run python (to have interactive python shell), and do that:
import python
You should have same errors as WeeChat.
|
Mon 20 Sep 2010 09:44:32 PM UTC, original submission:
When I use "import gtk" or a library that uses gtk in a python plugin, weechat throws an error:
python: stdout/stderr: Traceback (most recent call last):
python: stdout/stderr: File "/home/leon/.weechat/python/windicate.py", line 24, in <module>
python: stdout/stderr: import gtk
python: stdout/stderr: File "/usr/lib/pymodules/python2.6/gtk-2.0/gtk/__init__.py", line 42, in <module>
python: stdout/stderr: import gdk
python: stdout/stderr: ImportError: No module named gdk
python: unable to parse file "/home/leon/.weechat/python/windicate.py"
When I use import gtk in a standalone script or in ipython it doesn't throw an error.
|