[C++-sig] Python/C PyRun_String

Venkatraman S venkat83 at gmail.com
Sat Mar 29 02:36:10 CET 2008


Hi All,

Am using Pythong/C API for embedding. I have written a small-simple wrapper
that does the low level functions and exposes the functionalities in a c++
style(i.,e the application layer doensnt use 'PyObject'). I am reading the
contents of a file(Python script) and am running the same using
PyRun_String; the script setups some variables in the Main Dict which i
access it using the PyArg_Parse...etc etc(the standard way). This keeps
running in a loop - i.,e it needs to be processed for every transaction -
hence the Python wrapper is a singleton which preserves the main dict.

Am stumbling on a problem wherein when i try to access a variable in Python
from C as a string - this variable in python was constructed by
concatenating a float with a string(using 'str'), and hence the resulting
python variable is also a string. If i comment out the variable , then the
program runs fine; else it(C program) throws out a segmentation fault. A
clueless as to how to debug this and suitable hints would be immense help.
(If required , i can share the code for this - i just didnt want to send it
here)

Secondly, can anyone point me to the Boost::python way of embedding -
basically, i would like to know how to build/compile the program without
using bjam.

Regards,
-- 
Venkat
Blog @ http://blizzardzblogs.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080329/34b8ca4d/attachment.htm>


More information about the Cplusplus-sig mailing list