[mod_python] mysqldb calls cause segfault

Erdi Balint erdibalint at freemail.hu
Sun Oct 9 15:42:45 EDT 2005

Thank you, Nicolas, that fixed that problem, but now I have another one,
when importing a module from the MySQLdb module, I get the following 

   File "/var/www/trivia/control/trivia.py", line 5, in _connect
     db = MySQLdb.connect(user="xxx",passwd="xxx",db="xxx")

   File "/usr/lib/python2.3/site-packages/MySQLdb/__init__.py", line 66, 
in Connect
     return Connection(*args, **kwargs)

   File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line 
117, in __init__
     from converters import conversions

   File "/usr/lib/python2.3/site-packages/MySQLdb/converters.py", line 
40, in ?
     import array

ImportError: /usr/lib/python2.3/lib-dynload/array.so: undefined symbol: 

I've come across a python faq item, that says the following about the 
cause of the error:

If instead the name of the undefined symbol starts with PyUnicodeUCS4, 
the problem is the reverse: Python was built using 2-byte Unicode 
characters, and the extension module was compiled using a Python with 
4-byte Unicode characters.

You can check the size of the Unicode character a Python interpreter is 
using by checking the value of sys.maxunicode:

 >>> import sys
 >>> if sys.maxunicode > 65535:
...     print 'UCS4 build'
... else:
...     print 'UCS2 build'

Ok, so in theory, my Python interpreter uses 2-byte Unicode characters, 
but I've checked it (I am python 2.3.5) with the above code snipplet, 
and it is not so, I am using 4-byte Unicode characters? Then why is the 

Thank you for your help,

Nicolas Lehuen wrote:
> Hi Erdi,
> Have a look at this FAQ entry, it may be related to your problem :
> http://www.modpython.org/FAQ/faqw.py?req=show&file=faq02.013.htp 
> <http://www.modpython.org/FAQ/faqw.py?req=show&file=faq02.013.htp>
> Regards,
> Nicolas
> 2005/10/9, Erdi Balint <erdibalint at freemail.hu 
> <mailto:erdibalint at freemail.hu>>:
>     Hi all,
>     I am trying to write a small python-mysql application with mod_python
>     but got stuck right at the beginning. The following code snippet:
>          import MySQLdb
>          db = MySQLdb.connect(user="xxx",passwd="xxx",db="xxx")
>          return db
>     causes a Segmentation fault.
>     apache log:
>     [Sun Oct  9 11:09:52 2005] [notice] child pid 6736 exit signal
>     Segmentation fault (11)
>     (in fact, any mysql db operation causes the same)
>     I am using python-mysqldb version 1.2.1c3-2 and libapache-mod-python
>     version 2.7.10-4 (both installed from Debian packages, thinking that
>     they were stable releases). Apache version is 1.3.33. Am I doing
>     something wrong?
>     Thank you for your help,
>     Balint
>     _______________________________________________
>     Mod_python mailing list
>     Mod_python at modpython.org <mailto:Mod_python at modpython.org>
>     http://mailman.modpython.org/mailman/listinfo/mod_python

More information about the Mod_python mailing list