@@ -2410,31 +2410,23 @@ change in future releases of Python.
24102410 :ctype: `PyFileObject `.
24112411
24122412
2413- .. cfunction :: PyObject* PyFile_FromString( char *filename , char *mode)
2413+ .. cfunction :: PyFile_FromFd(int fd, char *name , char *mode, int buffering, char *encoding, char *newline )
24142414
2415- .. index :: single: fopen()
2416-
2417- On success, return a new file object that is opened on the file given by
2418- *filename *, with a file mode given by *mode *, where *mode * has the same
2419- semantics as the standard C routine :cfunc: `fopen `. On failure, return *NULL *.
2420-
2421-
2422- .. cfunction :: PyObject* PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE*))
2415+ Create a new :ctype: `PyFileObject ` from the file descriptor of an already
2416+ opened file *fd *. The arguments *name *, *encoding * and *newline * can be
2417+ *NULL * as well as buffering can be *-1 * to use the defaults. Return *NULL * on
2418+ failure.
24232419
2424- Create a new :ctype: `PyFileObject ` from the already-open standard C file
2425- pointer, *fp *. The function *close * will be called when the file should be
2426- closed. Return *NULL * on failure.
2420+ .. warning ::
24272421
2428- .. cfunction :: PyFile_FromFileEx(FILE *fp, char *name, char *mode, int (*close)(FILE *), int buffering, char *encoding, char *newline)
2422+ Take care when you are mixing streams and descriptors! For more
2423+ information, see `GNU C Library
2424+ <http://www.gnu.org/software/libc/manual/html_node/Stream_002fDescriptor-Precautions.html#Stream_002fDescriptor-Precautions> `_.
24292425
2430- Create a new :ctype: `PyFileObject ` from the already-open standard C file
2431- pointer, *fp *. The functions works similar to *PyFile_FromFile * but takes
2432- optional arguments for *buffering *, *encoding * and *newline *. Use -1 resp.
2433- *NULL * for default values.
24342426
2435- .. cfunction :: FILE* PyFile_AsFile (PyObject *p)
2427+ .. cfunction :: int PyObject_AsFileDescriptor (PyObject *p)
24362428
2437- Return the file object associated with *p * as a :ctype: `FILE \* `.
2429+ Return the file descriptor associated with *p * as an :ctype: `int `.
24382430
24392431
24402432.. cfunction :: PyObject* PyFile_GetLine(PyObject *p, int n)
0 commit comments