Access violation while trying to replace stdout with a local disk file

SINICA huiray at
Mon Nov 29 12:35:34 EST 1999

Hi there !

I'm trying to redirect the output of Python into a external diskfile
since my program and python interpretor are two different processes
(python15.dll and myprog.exe)
PyObject_Print() will cause a "Access Violation" while trying to
print on the file handle which is created by myprog.exe

any suggestion will be greatly appreciated.

please cc to csyap at
thank you in advance.


=====================SAMPLE CODE========================
FILE *output;
PyObject *new_stdout;

output = fopen("adiskfile","w");

new_stdout = PyFile_FromFile(output, "<stdout>", "w", NULL);
PySys_SetObject("stdout", new_stdout);

fprintf(output,"testing");    // <- it works

 v = PyRun_String("print 1+2", Py_single_input, globals, globals);   // <-
it doesn't works

More information about the Python-list mailing list