[Python-modules-team] Bug#526513: ImportError when using MySQLdb in embedded python

Phil Ashby phil.ashby at bt.com
Fri May 1 16:24:47 UTC 2009


Package: python-mysqldb
Version: 1.2.2-7

On Debian GNU/Linux 5.0 (lenny). Python 2.5.2-3.

When python is embedded in a shared library (in my case a plugin), the
_mysql.so component of MySQLdb fails to load, due to this error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: /var/lib/python-support/python2.5/_mysql.so: undefined
symbol: PyExc_ImportError

Discovered while trying to use the ida2sql.py script within IDAPython.

A simple example program is attached demonstrating the problem clearly,
this sample program also demonstrates a work-around, by setting the
RTLD_GLOBAL flag when loading the shared library, the necessary python
symbols are exported for _mysql.so and it loads correctly. Unfortunately
this isn't possible in my situation since IDA Pro is not open source,
and in general I think it's unwise for an application to export all the
symbols from any plugins it may load as there is a high probability of a
symbol collision.

I have also been able to work around this issue by re-linking _mysql.so
and including a direct dependancy on libpython2.5.so.1.0. This may not
be the right thing to do when using MySQLdb from the standard python
interpreter however?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pymain.c
Type: text/x-csrc
Size: 369 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/python-modules-team/attachments/20090501/4e7a38fb/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pysql.c
Type: text/x-csrc
Size: 135 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/python-modules-team/attachments/20090501/4e7a38fb/attachment-0001.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: makefile
Type: text/x-makefile
Size: 151 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/python-modules-team/attachments/20090501/4e7a38fb/attachment.bin>


More information about the Python-modules-team mailing list