Need help with PyRun_SimpleFile

Scott Shillcock shillcoc at mry.rbd.com
Sun Aug 29 02:46:33 EDT 1999


Hello,

Here is my very simple program:

#include <iostream.h>
#include "Python.h"

void
main (int argc, char **argv) {

   Py_Initialize ();
   FILE *fp = fopen ("test.py", "r+");
   cerr << "Before PyRun_SimpleFile" << endl;
   PyRun_SimpleFile (fp, "test.py");
   cerr << "After PyRun_SimpleFile" << endl;
   Py_Exit(0);
}

I can compile this into an exe file. I also created a very simple
test.py file that just prints one line of text. When I run my program it
crashes on the PyRun_SimpleFile() every time. I get the first cerr but
not the second.

What I am doing wrong? I have tried as many variations on this at I
could think of, all with the same result.

Thanks,
Scott

-- 
Scott Shillcock      shillcoc at rbd.com
Reality by Design         www.rbd.com




More information about the Python-list mailing list