PyImport_ImportModule("cStringIO") failure with undefinedsymbol

B

Borse, Ganesh

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...902b14?lnk=gst&q=PyErr_Print#f0bd5f5b15902b14

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_email_ib.html
==============================================================================
 
G

grbgooglefan

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/...

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top