Re: psycopg2 and python built with ucs2
От | Scott Rohde |
---|---|
Тема | Re: psycopg2 and python built with ucs2 |
Дата | |
Msg-id | CAEPRSL-kf2v=xEESFWutxtYSron=V8erXJDHNXx_rz81XXU5wg@mail.gmail.com обсуждение исходный текст |
Ответ на | psycopg2 and python built with ucs2 (Scott Rohde <srohde@gmail.com>) |
Список | psycopg |
Thought I'd reply to myself. Better late than never. The answer is yes, there is a simple way to get psycopg to work with python built with ucs2. If you're seeing the following error: ImportError: /usr/local/lib/python2.4/site-packages/psycopg2/_psycopg.so: undefined symbol: PyUnicodeUCS4_Decode You have two choices: 1. recompile python with ucs4 OR, 2. recompile psycopg2 with a python that was built with ucs2 As far as I can tell, psycopg2 makes no assumption on the unicode width - it will work with whatever python it's compiled with. For 1., pass '--enable-unicode=ucs4' to python's configure script and build python For 2., run the setup.py script with a ucs2 python (i.e. `python-built-with-ucs2 setup.py build`) pythons unicode C api was designed as follows (from unicodeobject.h): /* --- UCS-2/UCS-4 Name Mangling ------------------------------------------ */ /* Unicode API names are mangled to assure that UCS-2 and UCS-4 builds produce different external names and thus cause import errors in case Python interpreters and extensions with mixed compiled in Unicode width assumptions are combined. */ #ifndef Py_UNICODE_WIDE ... # define PyUnicode_Decode PyUnicodeUCS2_Decode ... #else ... # define PyUnicode_Decode PyUnicodeUCS4_Decode ... Regards, Scott On Fri, Jul 29, 2011 at 10:01 AM, Scott Rohde <srohde@gmail.com> wrote: > Hello, > > When I import psycopg2 from python built with ucs2 I get the following error: > ImportError: /usr/local/lib/python2.4/site-packages/psycopg2/_psycopg.so: > undefined symbol: PyUnicodeUCS4_Decode > > By recompiling python to use ucs4 this error goes away and I can > successfully use psycopg2. > > However, in my situation it would be much more convenient if I could > get psycopg2 to work with python built with ucs2. Is there a simple > way to do that? > > Thanks very much, > > -- > -Scott > -- -Scott
В списке psycopg по дате отправления: