Embedding (PyRun_SimpleFile)
nick_knight at my-deja.com
nick_knight at my-deja.com
Thu Aug 3 02:23:20 EDT 2000
In article <8F848A917gmcmhypernetcom at 199.171.54.154>,
gmcm at hypernet.com (Gordon McMillan) wrote:
> nick_knight at my-deja.com wrote:
>
> >I am trying to use the following code ( on a windows platform)
>
> [snip]
>
> >int main(int argc, char* argv[])
> >{
> > char *filename = "e:\\downloads\\python\\testbed\\test.py";
> > Py_Initialize(); //Required
> >
> > FILE *OurFile = fopen(filename,"rb");
> > PyRun_SimpleFile(OurFile,filename);
> > //PyRun_SimpleString("print 'Hello'");
> > return 0;
> >}
> >
> >- where thr file test.py contains
> >print "Hello"
> >
> >every time I run the program ,
> >
> >'import exceptions' failed; use -v for traceback
> >Warning! Falling back to string-based exceptions
> >'import site' failed; use -v for traceback
>
> Python can't figure out what sys.path should be.
>
> >gets printed out to stdio, also when the program enters
> >PyRun_SimpleFile MSVC comes up with a unhandled exeption
>
> Since you can't be bothered to tell us what the exception is, I'll
guess
> that you're not using the same c runtime Python is, so when you pass
that
> FILE * from your code to Python, msvcrt.dll (which is what Python
uses)
> doesn't like it.
>
> -Gordon
>
I appologise - I should have been more specific, Windows reports
Unhandled Exeption in testbed.exe(KERNEL32.dll) 0x0000005 Access
Violation, this is occurring in file /Parser/tokenizer.c on line 270
(when it attemtps to read a line from the file)
Thanks again
Nick
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list