summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/concrete.rst
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-10-22 00:09:51 (GMT)
committerGuido van Rossum <guido@python.org>2007-10-22 00:09:51 (GMT)
commit40d20bcf1fccfe8af2393f1aec88ba18e38d0bc1 (patch)
tree0d6616333b9c3cb004b659751fe9baa4bac67ad2 /Doc/c-api/concrete.rst
parentc2954e5273520031d3debfac8c668b9e611303b3 (diff)
downloadcpython-40d20bcf1fccfe8af2393f1aec88ba18e38d0bc1.zip
cpython-40d20bcf1fccfe8af2393f1aec88ba18e38d0bc1.tar.gz
cpython-40d20bcf1fccfe8af2393f1aec88ba18e38d0bc1.tar.bz2
Issue 1267, continued.
Additional patch by Christian Heimes to deal more cleanly with the FILE* vs file-descriptor issues. I cleaned up his code a bit, and moved the lseek() call into import.c.
Diffstat (limited to 'Doc/c-api/concrete.rst')
-rw-r--r--Doc/c-api/concrete.rst30
1 files changed, 11 insertions, 19 deletions
diff --git a/Doc/c-api/concrete.rst b/Doc/c-api/concrete.rst
index e48056c..1855688 100644
--- a/Doc/c-api/concrete.rst
+++ b/Doc/c-api/concrete.rst
@@ -2410,31 +2410,23 @@ change in future releases of Python.
:ctype:`PyFileObject`.
-.. cfunction:: PyObject* PyFile_FromString(char *filename, char *mode)
+.. cfunction:: PyFile_FromFd(int fd, char *name, char *mode, int buffering, char *encoding, char *newline)
- .. index:: single: fopen()
-
- On success, return a new file object that is opened on the file given by
- *filename*, with a file mode given by *mode*, where *mode* has the same
- semantics as the standard C routine :cfunc:`fopen`. On failure, return *NULL*.
-
-
-.. cfunction:: PyObject* PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE*))
+ Create a new :ctype:`PyFileObject` from the file descriptor of an already
+ opened file *fd*. The arguments *name*, *encoding* and *newline* can be
+ *NULL* as well as buffering can be *-1* to use the defaults. Return *NULL* on
+ failure.
- Create a new :ctype:`PyFileObject` from the already-open standard C file
- pointer, *fp*. The function *close* will be called when the file should be
- closed. Return *NULL* on failure.
+ .. warning::
-.. cfunction:: PyFile_FromFileEx(FILE *fp, char *name, char *mode, int (*close)(FILE *), int buffering, char *encoding, char *newline)
+ Take care when you are mixing streams and descriptors! For more
+ information, see `GNU C Library
+ <http://www.gnu.org/software/libc/manual/html_node/Stream_002fDescriptor-Precautions.html#Stream_002fDescriptor-Precautions>`_.
- Create a new :ctype:`PyFileObject` from the already-open standard C file
- pointer, *fp*. The functions works similar to *PyFile_FromFile* but takes
- optional arguments for *buffering*, *encoding* and *newline*. Use -1 resp.
- *NULL* for default values.
-.. cfunction:: FILE* PyFile_AsFile(PyObject *p)
+.. cfunction:: int PyObject_AsFileDescriptor(PyObject *p)
- Return the file object associated with *p* as a :ctype:`FILE\*`.
+ Return the file descriptor associated with *p* as an :ctype:`int`.
.. cfunction:: PyObject* PyFile_GetLine(PyObject *p, int n)