[C++-sig] Exception using boost::python and PyRun_file

Simon Pickles sipickles at hotmail.com
Fri Jun 1 22:48:32 CEST 2007


Hi,

[newbie alert]

I am trying to embed python in c++ with boost::python. I'm using

MSVC++ 2005 Express
Boost 1.34
Python 2.52


Unfortunately, I've come unstuck already.

Here's my code

    object main_module( ( handle<>( borrowed( PyImport_AddModule( "__main__" 
) ) ) ) );

    object main_namespace = main_module.attr("__dict__");

    FILE* myPython = fopen( "myPython.py", "r" );

    handle<> ignored( ( PyRun_File( myPython, "myPython.py",
                        Py_file_input,
                        main_namespace.ptr(),
                        main_namespace.ptr() ) ) );

    fclose( myPython );




and heres the exception:

First-chance exception at 0x7c918fea in Server 20070601.exe: 0xC0000005:
Access violation writing location 0x00000010.
Unhandled exception at 0x7c918fea in Server 20070601.exe: 0xC0000005:
Access violation writing location 0x00000010.


What am I doing wrong? must be something simple :)

Thanks!

Simon




http://www.simonpickles.com  --- http://www.squirtualreality.com

_________________________________________________________________
Play your part in making history - Email Britain! 
http://www.emailbritain.co.uk/




More information about the Cplusplus-sig mailing list