[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

PyImport_ImportModule("cStringIO") failure with undefined symbol

Borse, Ganesh

1/11/2008 1:31:00 AM

Hi,
Can you please guide me for the following problem?
The call to "PyImport_ImportModule("cStringIO");" is failing with an error of "undefined symbol: PyObject_SelfIter".

Before importing this module, I am importing only the sys module.

Py_SetProgramName("/usr/bin/python");
Py_Initialize();
char* argv[] = { "python","-v",""};
PySys_SetArgv(2,argv);
PyRun_SimpleString("import sys");

PyObject *modStringIO = NULL;
// Import cStringIO module
modStringIO = PyImport_ImportModule("cStringIO");

Should I be importing any other additional module(s) to make this import work?

Please help.

I am trying to use the function GetPythonErrorMessage provided in this post:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/9212ebc42e8438a7/f0bd5f5b15902b14?lnk=gst&q=PyErr_Print#f0bd5f...

Thanks in advance for your help.
Regards.

==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:

http://www.credit-suisse.com/legal/en/disclaimer_ema...
==============================================================================

1 Answer

grbgooglefan

1/31/2008 10:49:00 AM

0

On Jan 11, 9:31 am, "Borse, Ganesh" <ganesh.bo...@credit-suisse.com>
wrote:
> Hi,
> Can you please guide me for the following problem?
> The call to "PyImport_ImportModule("cStringIO");" is failing with an error of "undefined symbol:PyObject_SelfIter".
>
> Before importing this module, I am importing only the sys module.
>
>    Py_SetProgramName("/usr/bin/python");
>    Py_Initialize();
>    char* argv[] = { "python","-v",""};
>    PySys_SetArgv(2,argv);
>    PyRun_SimpleString("import sys");
>
>    PyObject *modStringIO = NULL;
>    // Import cStringIO module
>    modStringIO = PyImport_ImportModule("cStringIO");
>
> Should I be importing any other additional module(s) to make this import work?
>
> Please help.
>
> I am trying to use the function GetPythonErrorMessage provided in this post:http://groups.google.com/group/comp.lang.python/browse_thre......
>
> Thanks in advance for your help.
> Regards.
==========================================

Function "PyObject_SelfIter" is part of libPython.a. But when library
which is linked with libPython.a tries to import cStringIO (which is
nothing but dlopen("lib-dynload/cStringIO.so"), ld.so does not find
this symbol.
So, as a workaround, we can get the cStringIO.so also linked with the
library which has linked libPython.a.
By this we ensure that PyObject_SelfIter is already resolved in the
library.
Then at the time of importing cStringIO at runtime, this symbol is
already referenced & won't cause problems.