PyFile_AsFile( ) question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gaspard, Bradley S

    PyFile_AsFile( ) question

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

    f = open("foobar.tx t", "w")

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

    EnumWinsatError Code SetOutStream(Py Object *fileObj)
    {
    FILE *fp;

    if ((fp = PyFile_AsFile(f ileObj)) == 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_SUCC ESS;
    }

    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??

Working...