Hi, hi! New user, and probably making some silly mistakes, but a few hours with search engines have not provided an answer...

Problem:
I'm trying to embed Python routines in a DLL and it's not working.

Platform and versions:
Python 2.7.3 (I have been unable to get boost to compile/link to python 3)
Boost 1.54 (svn 84094)
Windows 7 (x32) - MSVC 9

Detailed problem:
When calling Py_Initialize() an assertion fails the program crashes in object.c line 65-
  assert((op->_ob_prev == NULL) == (op->_ob_next == NULL));

Test Code:
   Py_Initialize(); /* Failure point */
   m_main_module = boost::python::import("__main__");
   m_main_namespace = m_main_module.attr("__dict__");
   boost::python::exec("result = 5 ** 2", m_main_namespace);
int Tester = boost::python::extract<int>(m_main_namespace["result"]);

Values:
+ op 0x05be172c __Py_NoneStruct {_ob_next=0x00000011 _ob_prev=0x00000000 ob_refcnt=17 ...} _object * + op->_ob_next 0x00000011 {_ob_next=??? _ob_prev=??? ob_refcnt=??? ...} _object * + op->_ob_prev 0x00000000 {_ob_next=??? _ob_prev=??? ob_refcnt=??? ...} _object *
Partial Call Stack:
        msvcr90d.dll!__wassert()  + 0xb64 bytes
python27_d.dll!_Py_AddToAllObjects(_object * op=0x05be172c, int force=0) Line 65 + 0x2d bytes C
        python27_d.dll!_PyBuiltin_Init()  Line 2680 + 0x2d bytes        C
python27_d.dll!Py_InitializeEx(int install_sigs=1) Line 214 + 0x5 bytes C
        python27_d.dll!Py_Initialize()  Line 377 + 0x7 bytes    C
pySim_plugd.dll!PySimProcessor::PySimProcessor() Line 73 + 0x8 bytes C++



Attempted solutions:
Tried adding call to Py_Initialize() from main() - Call succeeded, but no effect on module. Tried moving call to Py_Initialize() from main() - Python code fails to execute.
Tried duplicating same code in different application - succeeded. =(

Thanks for reading!


_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to