Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Doc/c-api/file.rst

    r2 r391  
    88.. index:: object: file
    99
    10 Python's built-in file objects are implemented entirely on the :ctype:`FILE\*`
     10Python's built-in file objects are implemented entirely on the :c:type:`FILE\*`
    1111support from the C standard library.  This is an implementation detail and may
    1212change in future releases of Python.
    1313
    1414
    15 .. ctype:: PyFileObject
     15.. c:type:: PyFileObject
    1616
    17    This subtype of :ctype:`PyObject` represents a Python file object.
     17   This subtype of :c:type:`PyObject` represents a Python file object.
    1818
    1919
    20 .. cvar:: PyTypeObject PyFile_Type
     20.. c:var:: PyTypeObject PyFile_Type
    2121
    2222   .. index:: single: FileType (in module types)
    2323
    24    This instance of :ctype:`PyTypeObject` represents the Python file type.  This is
     24   This instance of :c:type:`PyTypeObject` represents the Python file type.  This is
    2525   exposed to Python programs as ``file`` and ``types.FileType``.
    2626
    2727
    28 .. cfunction:: int PyFile_Check(PyObject *p)
     28.. c:function:: int PyFile_Check(PyObject *p)
    2929
    30    Return true if its argument is a :ctype:`PyFileObject` or a subtype of
    31    :ctype:`PyFileObject`.
     30   Return true if its argument is a :c:type:`PyFileObject` or a subtype of
     31   :c:type:`PyFileObject`.
    3232
    3333   .. versionchanged:: 2.2
     
    3535
    3636
    37 .. cfunction:: int PyFile_CheckExact(PyObject *p)
     37.. c:function:: int PyFile_CheckExact(PyObject *p)
    3838
    39    Return true if its argument is a :ctype:`PyFileObject`, but not a subtype of
    40    :ctype:`PyFileObject`.
     39   Return true if its argument is a :c:type:`PyFileObject`, but not a subtype of
     40   :c:type:`PyFileObject`.
    4141
    4242   .. versionadded:: 2.2
    4343
    4444
    45 .. cfunction:: PyObject* PyFile_FromString(char *filename, char *mode)
     45.. c:function:: PyObject* PyFile_FromString(char *filename, char *mode)
    4646
    4747   .. index:: single: fopen()
     
    4949   On success, return a new file object that is opened on the file given by
    5050   *filename*, with a file mode given by *mode*, where *mode* has the same
    51    semantics as the standard C routine :cfunc:`fopen`.  On failure, return *NULL*.
     51   semantics as the standard C routine :c:func:`fopen`.  On failure, return *NULL*.
    5252
    5353
    54 .. cfunction:: PyObject* PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE*))
     54.. c:function:: PyObject* PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE*))
    5555
    56    Create a new :ctype:`PyFileObject` from the already-open standard C file
     56   Create a new :c:type:`PyFileObject` from the already-open standard C file
    5757   pointer, *fp*.  The function *close* will be called when the file should be
    58    closed.  Return *NULL* on failure.
     58   closed.  Return *NULL* and close the file using *close* on failure.
     59   *close* is optional and can be set to *NULL*.
    5960
    6061
    61 .. cfunction:: FILE* PyFile_AsFile(PyObject \*p)
     62.. c:function:: FILE* PyFile_AsFile(PyObject \*p)
    6263
    63    Return the file object associated with *p* as a :ctype:`FILE\*`.
     64   Return the file object associated with *p* as a :c:type:`FILE\*`.
    6465
    65    If the caller will ever use the returned :ctype:`FILE\*` object while
    66    the GIL is released it must also call the :cfunc:`PyFile_IncUseCount` and
    67    :cfunc:`PyFile_DecUseCount` functions described below as appropriate.
     66   If the caller will ever use the returned :c:type:`FILE\*` object while
     67   the :term:`GIL` is released it must also call the :c:func:`PyFile_IncUseCount` and
     68   :c:func:`PyFile_DecUseCount` functions described below as appropriate.
    6869
    6970
    70 .. cfunction:: void PyFile_IncUseCount(PyFileObject \*p)
     71.. c:function:: void PyFile_IncUseCount(PyFileObject \*p)
    7172
    7273   Increments the PyFileObject's internal use count to indicate
    73    that the underlying :ctype:`FILE\*` is being used.
     74   that the underlying :c:type:`FILE\*` is being used.
    7475   This prevents Python from calling f_close() on it from another thread.
    75    Callers of this must call :cfunc:`PyFile_DecUseCount` when they are
    76    finished with the :ctype:`FILE\*`.  Otherwise the file object will
     76   Callers of this must call :c:func:`PyFile_DecUseCount` when they are
     77   finished with the :c:type:`FILE\*`.  Otherwise the file object will
    7778   never be closed by Python.
    7879
    79    The GIL must be held while calling this function.
     80   The :term:`GIL` must be held while calling this function.
    8081
    81    The suggested use is to call this after :cfunc:`PyFile_AsFile` just before
    82    you release the GIL.
     82   The suggested use is to call this after :c:func:`PyFile_AsFile` and before
     83   you release the GIL::
     84
     85      FILE *fp = PyFile_AsFile(p);
     86      PyFile_IncUseCount(p);
     87      /* ... */
     88      Py_BEGIN_ALLOW_THREADS
     89      do_something(fp);
     90      Py_END_ALLOW_THREADS
     91      /* ... */
     92      PyFile_DecUseCount(p);
    8393
    8494   .. versionadded:: 2.6
    8595
    8696
    87 .. cfunction:: void PyFile_DecUseCount(PyFileObject \*p)
     97.. c:function:: void PyFile_DecUseCount(PyFileObject \*p)
    8898
    8999   Decrements the PyFileObject's internal unlocked_count member to
    90    indicate that the caller is done with its own use of the :ctype:`FILE\*`.
    91    This may only be called to undo a prior call to :cfunc:`PyFile_IncUseCount`.
     100   indicate that the caller is done with its own use of the :c:type:`FILE\*`.
     101   This may only be called to undo a prior call to :c:func:`PyFile_IncUseCount`.
    92102
    93    The GIL must be held while calling this function.
     103   The :term:`GIL` must be held while calling this function (see the example
     104   above).
    94105
    95106   .. versionadded:: 2.6
    96107
    97108
    98 .. cfunction:: PyObject* PyFile_GetLine(PyObject *p, int n)
     109.. c:function:: PyObject* PyFile_GetLine(PyObject *p, int n)
    99110
    100111   .. index:: single: EOFError (built-in exception)
    101112
    102113   Equivalent to ``p.readline([n])``, this function reads one line from the
    103    object *p*.  *p* may be a file object or any object with a :meth:`readline`
     114   object *p*.  *p* may be a file object or any object with a
     115   :meth:`~io.IOBase.readline`
    104116   method.  If *n* is ``0``, exactly one line is read, regardless of the length of
    105117   the line.  If *n* is greater than ``0``, no more than *n* bytes will be read
     
    110122
    111123
    112 .. cfunction:: PyObject* PyFile_Name(PyObject *p)
     124.. c:function:: PyObject* PyFile_Name(PyObject *p)
    113125
    114126   Return the name of the file specified by *p* as a string object.
    115127
    116128
    117 .. cfunction:: void PyFile_SetBufSize(PyFileObject *p, int n)
     129.. c:function:: void PyFile_SetBufSize(PyFileObject *p, int n)
    118130
    119131   .. index:: single: setvbuf()
    120132
    121    Available on systems with :cfunc:`setvbuf` only.  This should only be called
     133   Available on systems with :c:func:`setvbuf` only.  This should only be called
    122134   immediately after file object creation.
    123135
    124136
    125 .. cfunction:: int PyFile_SetEncoding(PyFileObject *p, const char *enc)
     137.. c:function:: int PyFile_SetEncoding(PyFileObject *p, const char *enc)
    126138
    127139   Set the file's encoding for Unicode output to *enc*. Return 1 on success and 0
     
    131143
    132144
    133 .. cfunction:: int PyFile_SetEncodingAndErrors(PyFileObject *p, const char *enc, *errors)
     145.. c:function:: int PyFile_SetEncodingAndErrors(PyFileObject *p, const char *enc, *errors)
    134146
    135147   Set the file's encoding for Unicode output to *enc*, and its error
     
    139151
    140152
    141 .. cfunction:: int PyFile_SoftSpace(PyObject *p, int newflag)
     153.. c:function:: int PyFile_SoftSpace(PyObject *p, int newflag)
    142154
    143155   .. index:: single: softspace (file attribute)
     
    153165
    154166
    155 .. cfunction:: int PyFile_WriteObject(PyObject *obj, PyObject *p, int flags)
     167.. c:function:: int PyFile_WriteObject(PyObject *obj, PyObject *p, int flags)
    156168
    157169   .. index:: single: Py_PRINT_RAW
     
    163175
    164176
    165 .. cfunction:: int PyFile_WriteString(const char *s, PyObject *p)
     177.. c:function:: int PyFile_WriteString(const char *s, PyObject *p)
    166178
    167179   Write string *s* to file object *p*.  Return ``0`` on success or ``-1`` on
Note: See TracChangeset for help on using the changeset viewer.