FS#27527 - [python2-gobject2][gvim] import glib in vim Python interface yields undefined symbol: PyExc_ImportE

Attached to Project: Arch Linux
Opened by Noé Rubinstein (Phlogistique) - Saturday, 10 December 2011, 23:30 GMT
Last edited by Eric Belanger (Snowman) - Sunday, 15 January 2012, 06:39 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Ionut Biru (wonder)
Jan Alexander Steffens (heftig)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:
Trying to import glib or any package importing glib in the vim :python command fails with an undefined symbol error.

I think the problem might be within Arch Linux because:
* Another Arch Linux user has told me on IRC that he was able to reproduce the problem.
* One Debian user and one Gentoo user both told me on IRC were unable to reproduce the problem.
* I have been unable to reproduce on Ubuntu 10.10 with python 2.6.6-2ubuntu2, vim 2:7.2.330-1ubuntu4, python-gobject 2.21.5-0ubuntu3, libglib2.0-0 2.26.1-0ubuntu1.

Additional info:
* glib 1.2.10-9
* python2-gobject2 2.28.6-4
* gvim 7.3.353-2
* python2 2.7.2-4

Steps to reproduce:
* Launch vim or gvim.
* type the following command :python import glib
* The following error appears:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/glib/__init__.py", line 22, in <module>
from glib._glib import *
ImportError: /usr/lib/libpyglib-2.0-python2.so.0: undefined symbol: PyExc_ImportE
rror
This task depends upon

Closed by  Eric Belanger (Snowman)
Sunday, 15 January 2012, 06:39 GMT
Reason for closing:  Fixed
Additional comments about closing:  python3 support was removed in vim-7.3.401-1
Comment by Noé Rubinstein (Phlogistique) - Saturday, 10 December 2011, 23:35 GMT
The formatting of the error message as been somewhat changed by the bugtracker, so here it is again.
Comment by Noé Rubinstein (Phlogistique) - Saturday, 10 December 2011, 23:38 GMT
Here is another backtrace, this time for ":python import dbus". Because the error is not in /usr/lib/libpyglib-2.0-python2.so.0 anymore, it is more likely that the problem is either in vim or in python2.

As a side-note: you can't reproduce this with the vim package as it is for some reason built without Python support whereas gvim is build with Python support.
Comment by Eric Belanger (Snowman) - Sunday, 11 December 2011, 02:18 GMT
it's a python2-gobject2 problem. I suppose the library should link to the python library:

$ ldd -r /usr/lib/libpyglib-2.0-python2.so.0
linux-vdso.so.1 => (0x00007fff40bff000)
libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x00007f2588341000)
libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0x00007f258813c000)
librt.so.1 => /lib/librt.so.1 (0x00007f2587f33000)
libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x00007f2587c3e000)
libffi.so.5 => /usr/lib/libffi.so.5 (0x00007f2587a36000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007f2587818000)
libc.so.6 => /lib/libc.so.6 (0x00007f2587491000)
libpcre.so.0 => /lib/libpcre.so.0 (0x00007f2587236000)
/lib/ld-linux-x86-64.so.2 (0x00007f25887c6000)
undefined symbol: PyExc_ImportError (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: _Py_ZeroStruct (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyExc_ValueError (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: _Py_NotImplementedStruct (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: _Py_TrueStruct (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: _Py_NoneStruct (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyCObject_Type (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyString_AsString (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyGILState_Release (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: _PyObject_CallFunction_SizeT (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyObject_IsTrue (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyErr_GivenExceptionMatches (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyErr_Format (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyFloat_FromDouble (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyErr_Occurred (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyEval_InitThreads (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyErr_SetObject (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyString_FromString (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyInt_FromLong (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyDict_GetItem (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyErr_Restore (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyInt_AsLong (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyCObject_AsVoidPtr (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyGILState_Ensure (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyErr_NormalizeException (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyObject_CallObject (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyErr_Fetch (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyObject_GetAttrString (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyObject_SetAttrString (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyErr_NewException (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyErr_Print (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyImport_ImportModule (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyThread_create_key (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyTuple_GetItem (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyErr_SetString (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyDict_SetItem (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyObject_Repr (/usr/lib/libpyglib-2.0-python2.so.0)
undefined symbol: PyDict_New (/usr/lib/libpyglib-2.0-python2.so.0)


Comment by Eric Belanger (Snowman) - Sunday, 11 December 2011, 02:23 GMT
dbus-python has a similar bug. You should open a bug report for it.
Comment by Jan Alexander Steffens (heftig) - Sunday, 11 December 2011, 04:20 GMT
Problem with -Wl,--as-needed?
Comment by Noé Rubinstein (Phlogistique) - Sunday, 11 December 2011, 04:46 GMT Comment by Ionut Biru (wonder) - Sunday, 11 December 2011, 08:35 GMT
works for me

$ python2
Python 2.7.2 (default, Nov 21 2011, 17:24:32)
[GCC 4.6.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from _dbus_bindings import ObjectPath, ByteArray, Signature, Byte
>>> from glib._glib import *
>>>
Comment by Ionut Biru (wonder) - Sunday, 11 December 2011, 08:36 GMT
i believe is your python2 library is a bit broken. tried to reinstall?
Comment by Noé Rubinstein (Phlogistique) - Sunday, 11 December 2011, 11:44 GMT
Ionut: please try using the "Steps to reproduce" in the bug report. Namely, use ":python import dbus" in vim or gvim.
Comment by Jan Alexander Steffens (heftig) - Monday, 12 December 2011, 14:11 GMT
Looks like building both python2 and python3 support into vim causes it to load the interpreter via dlopen() and RTLD_LOCAL, as they contain conflicting symbols. Since the symbols are not globally available, loading extensions not explicitly linked to the right libpython will fail.
Comment by Ray Rashif (schivmeister) - Tuesday, 13 December 2011, 03:07 GMT
And in the meantime anyone requiring this (python2) functionality can rebuild (g)vim with these changes:

-makedepends=('gpm' 'python2' 'python' 'ruby' 'libxt' 'desktop-file-utils' 'gtk2' 'lua')
+makedepends=('gpm' 'python2' 'ruby' 'libxt' 'desktop-file-utils' 'gtk2' 'lua')

- --enable-python3interp --enable-rubyinterp --enable-luainterp
+ --disable-python3interp --enable-rubyinterp --enable-luainterp

The Python3 interpreter is also known to cause Python omnicompletion to not work.
Comment by Jan Alexander Steffens (heftig) - Thursday, 15 December 2011, 22:25 GMT
So, looks like I can resolve this in one of the following ways:

- Remove python2 support
- Remove python3 support
- Keep the current state, in which some extensions fail to load

Any opinions?
Comment by Chen Xing (chenxing) - Tuesday, 20 December 2011, 02:52 GMT
Other libraries, like sip and matplotlib.pyplot, suffer from exactly the same problem: when imported in vim (:python import sip), the following error occurs:

Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: /usr/lib/python2.7/site-packages/sip.so: undefined symbol: PyProperty_Type

Rebuild gvim without Python3 support solves the problem. But probably brings incompatibility with Python3. Are there better solutions?
Comment by Eric Belanger (Snowman) - Tuesday, 20 December 2011, 04:31 GMT
I added python3 support as a user requested it:  FS#25529 . I didn't know it would conflict with the python2 support. I don't use vim so I don't really care. Probably the best solution would be to only enable either python2 or python3 support. I don't know which one it should be.
Comment by Eric Belanger (Snowman) - Wednesday, 11 January 2012, 08:18 GMT
I'm guessing that removing python3 support might be the best solution. Any ojections? Would it make more sense to remove python2 support instead as it's older? Should I ask on ML?
Comment by Chen Xing (chenxing) - Wednesday, 11 January 2012, 08:27 GMT
Thank you! I totally agree that having one of them working is better than neither works.

I personally vote for keeping Python2 support. Python2 has more libraries and is probably more widely used at this point.

Loading...