PyFile_AsFile( ) question

G

Gaspard, Bradley S

I want to open a file in python (version 2.2.3)

f = open("foobar.txt", "w")

and then pass the file's handle, f, to a "C" extention

EnumWinsatErrorCode SetOutStream(PyObject *fileObj)
{
FILE *fp;

if ((fp = PyFile_AsFile(fileObj)) == NULL) {
fprintf(stderr, "SetOutStream(): failed to obtain stream\n");
return WINSAT_SUP_TYPE_ERROR;
}

fprintf(fp, "This is a foobar\n"); // Causes windows application error

jglobal->debugout = fp;

return WINSAT_SUP_SUCCESS;
}

This works fine on my linux box. Under windows however I am getting fatal
error whenever I try and use the FILE * returned by PyFile_AsFile( ). Can
someone help me out??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,197
Messages
2,571,040
Members
47,634
Latest member
RonnyBoelk

Latest Threads

Top