By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,813 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,813 IT Pros & Developers. It's quick & easy.

PyFile_AsFile( ) question

P: n/a
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??

Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.