Message157559
| Author |
vstinner |
| Recipients |
doko, pitrou, vstinner |
| Date |
2012年04月05日.10:30:12 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1333621813.52.0.0442623539335.issue14505@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
> 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() */
...
}
...
Py_DECREF(obj);
Would you like to write a patch for the documentation? |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年04月05日 10:30:13 | vstinner | set | recipients:
+ vstinner, doko, pitrou |
| 2012年04月05日 10:30:13 | vstinner | set | messageid: <1333621813.52.0.0442623539335.issue14505@psf.upfronthosting.co.za> |
| 2012年04月05日 10:30:12 | vstinner | link | issue14505 messages |
| 2012年04月05日 10:30:12 | vstinner | create |
|