Author vstinner
Recipients doko, pitrou, vstinner
Date 2012-04-05.10:30:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> File descriptors opened by PyFile_FromString don't get closed
> when the reference count is decreased.

Correct, PyFile_FromString() doesn't close the file descriptor, even if you call its close() method. You have to call manually fclose(file->f_fp).

Or you can use PyFile_FromFile:

fp = fopen(name, mode);
if (fp == NULL) ...
obj = PyFile_FromFile(fp, name, mode, fclose);
if (obj == NULL) {
   /* no need to call fclose(fp) here, it's done by PyFile_FromFile() */

Would you like to write a patch for the documentation?
Date User Action Args
2012-04-05 10:30:13vstinnersetrecipients: + vstinner, doko, pitrou
2012-04-05 10:30:13vstinnersetmessageid: <>
2012-04-05 10:30:12vstinnerlinkissue14505 messages
2012-04-05 10:30:12vstinnercreate