Failing in a simple embedding example of python
Fredrik Lundh
fredrik at pythonware.com
Wed Mar 1 04:35:23 EST 2006
Themistoklis Bourdenas wrote:
> Hi I'm trying the following simple test in my application:
>
> FILE* fp = fopen("test.py", "r");
> PyRun_SimpleFile(fp, "test.py");
> fclose(fp);
>
>
> However I get seg fault is in PyRun_SimpleFile(fp, "test.py"). "test.py"
> is an existing file with a simple statement (print 7+4).
> When I try PyRun_SimpleString("..."); The script is running normally.
> What is the problem with this one?
since you're passing in a FILE object, you must make sure that you're
using the right runtime library:
http://mail.python.org/pipermail/python-list/1999-July/007766.html
(the above thread is the first hit if you google for PyRun_SimpleFile, btw.)
there's also a FAQ entry about this:
http://www.python.org/doc/faq/windows.html#pyrun-simplefile-crashes-on-windows-but-not-on-unix-why
which discusses some ways to work around this if you cannot fix the
runtime library issue.
hope this helps!
</F>
More information about the Python-list
mailing list