Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

Location:
python/vendor/current/Doc/c-api
Files:
3 added
54 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/Doc/c-api/abstract.rst

    r2 r388  
    1414
    1515It is not possible to use these functions on objects that are not properly
    16 initialized, such as a list object that has been created by :cfunc:`PyList_New`,
     16initialized, such as a list object that has been created by :c:func:`PyList_New`,
    1717but whose items have not been set to some non-\ ``NULL`` value yet.
    1818
  • python/vendor/current/Doc/c-api/allocation.rst

    r2 r388  
    77
    88
    9 .. cfunction:: PyObject* _PyObject_New(PyTypeObject *type)
     9.. c:function:: PyObject* _PyObject_New(PyTypeObject *type)
    1010
    1111
    12 .. cfunction:: PyVarObject* _PyObject_NewVar(PyTypeObject *type, Py_ssize_t size)
     12.. c:function:: PyVarObject* _PyObject_NewVar(PyTypeObject *type, Py_ssize_t size)
    1313
    1414   .. versionchanged:: 2.5
    15       This function used an :ctype:`int` type for *size*. This might require
     15      This function used an :c:type:`int` type for *size*. This might require
    1616      changes in your code for properly supporting 64-bit systems.
    1717
    1818
    19 .. cfunction:: void _PyObject_Del(PyObject *op)
     19.. c:function:: void _PyObject_Del(PyObject *op)
    2020
    2121
    22 .. cfunction:: PyObject* PyObject_Init(PyObject *op, PyTypeObject *type)
     22.. c:function:: PyObject* PyObject_Init(PyObject *op, PyTypeObject *type)
    2323
    2424   Initialize a newly-allocated object *op* with its type and initial
     
    2929
    3030
    31 .. cfunction:: PyVarObject* PyObject_InitVar(PyVarObject *op, PyTypeObject *type, Py_ssize_t size)
     31.. c:function:: PyVarObject* PyObject_InitVar(PyVarObject *op, PyTypeObject *type, Py_ssize_t size)
    3232
    33    This does everything :cfunc:`PyObject_Init` does, and also initializes the
     33   This does everything :c:func:`PyObject_Init` does, and also initializes the
    3434   length information for a variable-size object.
    3535
    3636   .. versionchanged:: 2.5
    37       This function used an :ctype:`int` type for *size*. This might require
     37      This function used an :c:type:`int` type for *size*. This might require
    3838      changes in your code for properly supporting 64-bit systems.
    3939
    4040
    41 .. cfunction:: TYPE* PyObject_New(TYPE, PyTypeObject *type)
     41.. c:function:: TYPE* PyObject_New(TYPE, PyTypeObject *type)
    4242
    4343   Allocate a new Python object using the C structure type *TYPE* and the
    4444   Python type object *type*.  Fields not defined by the Python object header
    4545   are not initialized; the object's reference count will be one.  The size of
    46    the memory allocation is determined from the :attr:`tp_basicsize` field of
     46   the memory allocation is determined from the :c:member:`~PyTypeObject.tp_basicsize` field of
    4747   the type object.
    4848
    4949
    50 .. cfunction:: TYPE* PyObject_NewVar(TYPE, PyTypeObject *type, Py_ssize_t size)
     50.. c:function:: TYPE* PyObject_NewVar(TYPE, PyTypeObject *type, Py_ssize_t size)
    5151
    5252   Allocate a new Python object using the C structure type *TYPE* and the
    5353   Python type object *type*.  Fields not defined by the Python object header
    5454   are not initialized.  The allocated memory allows for the *TYPE* structure
    55    plus *size* fields of the size given by the :attr:`tp_itemsize` field of
     55   plus *size* fields of the size given by the :c:member:`~PyTypeObject.tp_itemsize` field of
    5656   *type*.  This is useful for implementing objects like tuples, which are
    5757   able to determine their size at construction time.  Embedding the array of
     
    6060
    6161   .. versionchanged:: 2.5
    62       This function used an :ctype:`int` type for *size*. This might require
     62      This function used an :c:type:`int` type for *size*. This might require
    6363      changes in your code for properly supporting 64-bit systems.
    6464
    6565
    66 .. cfunction:: void PyObject_Del(PyObject *op)
     66.. c:function:: void PyObject_Del(PyObject *op)
    6767
    68    Releases memory allocated to an object using :cfunc:`PyObject_New` or
    69    :cfunc:`PyObject_NewVar`.  This is normally called from the
    70    :attr:`tp_dealloc` handler specified in the object's type.  The fields of
     68   Releases memory allocated to an object using :c:func:`PyObject_New` or
     69   :c:func:`PyObject_NewVar`.  This is normally called from the
     70   :c:member:`~PyTypeObject.tp_dealloc` handler specified in the object's type.  The fields of
    7171   the object should not be accessed after this call as the memory is no
    7272   longer a valid Python object.
    7373
    7474
    75 .. cfunction:: PyObject* Py_InitModule(char *name, PyMethodDef *methods)
     75.. c:function:: PyObject* Py_InitModule(char *name, PyMethodDef *methods)
    7676
    7777   Create a new module object based on a name and table of functions,
     
    8383
    8484
    85 .. cfunction:: PyObject* Py_InitModule3(char *name, PyMethodDef *methods, char *doc)
     85.. c:function:: PyObject* Py_InitModule3(char *name, PyMethodDef *methods, char *doc)
    8686
    8787   Create a new module object based on a name and table of functions,
     
    9494
    9595
    96 .. cfunction:: PyObject* Py_InitModule4(char *name, PyMethodDef *methods, char *doc, PyObject *self, int apiver)
     96.. c:function:: PyObject* Py_InitModule4(char *name, PyMethodDef *methods, char *doc, PyObject *self, int apiver)
    9797
    9898   Create a new module object based on a name and table of functions,
     
    108108
    109109      Most uses of this function should probably be using the
    110       :cfunc:`Py_InitModule3` instead; only use this if you are sure you need
     110      :c:func:`Py_InitModule3` instead; only use this if you are sure you need
    111111      it.
    112112
     
    116116
    117117
    118 .. cvar:: PyObject _Py_NoneStruct
     118.. c:var:: PyObject _Py_NoneStruct
    119119
    120120   Object which is visible in Python as ``None``.  This should only be
  • python/vendor/current/Doc/c-api/arg.rst

    r2 r388  
    1010:ref:`extending-index`.
    1111
    12 The first three of these functions described, :cfunc:`PyArg_ParseTuple`,
    13 :cfunc:`PyArg_ParseTupleAndKeywords`, and :cfunc:`PyArg_Parse`, all use
     12The first three of these functions described, :c:func:`PyArg_ParseTuple`,
     13:c:func:`PyArg_ParseTupleAndKeywords`, and :c:func:`PyArg_Parse`, all use
    1414*format strings* which are used to tell the function about the expected
    1515arguments.  The format strings use the same syntax for each of these
     
    2525of the C variable(s) whose address should be passed.
    2626
    27 ``s`` (string or Unicode object) [const char \*]
     27These formats allow to access an object as a contiguous chunk of memory.
     28You don't have to provide raw storage for the returned unicode or bytes
     29area.  Also, you won't have to release any memory yourself, except with the
     30``es``, ``es#``, ``et`` and ``et#`` formats.
     31
     32``s`` (string or Unicode) [const char \*]
    2833   Convert a Python string or Unicode object to a C pointer to a character
    2934   string.  You must not provide storage for the string itself; a pointer to
     
    3439   encoding.  If this conversion fails, a :exc:`UnicodeError` is raised.
    3540
    36 ``s#`` (string, Unicode or any read buffer compatible object) [const char \*, int (or :ctype:`Py_ssize_t`, see below)]
     41``s#`` (string, Unicode or any read buffer compatible object) [const char \*, int (or :c:type:`Py_ssize_t`, see below)]
    3742   This variant on ``s`` stores into two C variables, the first one a pointer
    3843   to a character string, the second one its length.  In this case the Python
     
    4348
    4449   Starting with Python 2.5 the type of the length argument can be controlled
    45    by defining the macro :cmacro:`PY_SSIZE_T_CLEAN` before including
    46    :file:`Python.h`.  If the macro is defined, length is a :ctype:`Py_ssize_t`
     50   by defining the macro :c:macro:`PY_SSIZE_T_CLEAN` before including
     51   :file:`Python.h`.  If the macro is defined, length is a :c:type:`Py_ssize_t`
    4752   rather than an int.
    4853
     
    5661   .. versionadded:: 2.6
    5762
    58 ``z`` (string or ``None``) [const char \*]
     63``z`` (string, Unicode or ``None``) [const char \*]
    5964   Like ``s``, but the Python object may also be ``None``, in which case the C
    6065   pointer is set to *NULL*.
    6166
    62 ``z#`` (string or ``None`` or any read buffer compatible object) [const char \*, int]
     67``z#`` (string, Unicode, ``None`` or any read buffer compatible object) [const char \*, int]
    6368   This is to ``s#`` as ``z`` is to ``s``.
    6469
    65 ``z*`` (string or ``None`` or any buffer compatible object) [Py_buffer]
     70``z*`` (string, Unicode, ``None`` or any buffer compatible object) [Py_buffer]
    6671   This is to ``s*`` as ``z`` is to ``s``.
    6772
    6873   .. versionadded:: 2.6
    6974
    70 ``u`` (Unicode object) [Py_UNICODE \*]
     75``u`` (Unicode) [Py_UNICODE \*]
    7176   Convert a Python Unicode object to a C pointer to a NUL-terminated buffer
    7277   of 16-bit Unicode (UTF-16) data.  As with ``s``, there is no need to
    7378   provide storage for the Unicode data buffer; a pointer to the existing
    74    Unicode data is stored into the :ctype:`Py_UNICODE` pointer variable whose
     79   Unicode data is stored into the :c:type:`Py_UNICODE` pointer variable whose
    7580   address you pass.
    7681
    77 ``u#`` (Unicode object) [Py_UNICODE \*, int]
     82``u#`` (Unicode) [Py_UNICODE \*, int]
    7883   This variant on ``u`` stores into two C variables, the first one a pointer
    7984   to a Unicode data buffer, the second one its length. Non-Unicode objects
    8085   are handled by interpreting their read-buffer pointer as pointer to a
    81    :ctype:`Py_UNICODE` array.
    82 
    83 ``es`` (string, Unicode object or character buffer compatible object) [const char \*encoding, char \*\*buffer]
     86   :c:type:`Py_UNICODE` array.
     87
     88``es`` (string, Unicode or character buffer compatible object) [const char \*encoding, char \*\*buffer]
    8489   This variant on ``s`` is used for encoding Unicode and objects convertible
    8590   to Unicode into a character buffer. It only works for encoded data without
     
    8792
    8893   This format requires two arguments.  The first is only used as input, and
    89    must be a :ctype:`const char\*` which points to the name of an encoding as
     94   must be a :c:type:`const char\*` which points to the name of an encoding as
    9095   a NUL-terminated string, or *NULL*, in which case the default encoding is
    9196   used.  An exception is raised if the named encoding is not known to Python.
    92    The second argument must be a :ctype:`char\*\*`; the value of the pointer
     97   The second argument must be a :c:type:`char\*\*`; the value of the pointer
    9398   it references will be set to a buffer with the contents of the argument
    9499   text.  The text will be encoded in the encoding specified by the first
    95100   argument.
    96101
    97    :cfunc:`PyArg_ParseTuple` will allocate a buffer of the needed size, copy
     102   :c:func:`PyArg_ParseTuple` will allocate a buffer of the needed size, copy
    98103   the encoded data into this buffer and adjust *\*buffer* to reference the
    99104   newly allocated storage.  The caller is responsible for calling
    100    :cfunc:`PyMem_Free` to free the allocated buffer after use.
    101 
    102 ``et`` (string, Unicode object or character buffer compatible object) [const char \*encoding, char \*\*buffer]
     105   :c:func:`PyMem_Free` to free the allocated buffer after use.
     106
     107``et`` (string, Unicode or character buffer compatible object) [const char \*encoding, char \*\*buffer]
    103108   Same as ``es`` except that 8-bit string objects are passed through without
    104109   recoding them.  Instead, the implementation assumes that the string object
    105110   uses the encoding passed in as parameter.
    106111
    107 ``es#`` (string, Unicode object or character buffer compatible object) [const char \*encoding, char \*\*buffer, int \*buffer_length]
     112``es#`` (string, Unicode or character buffer compatible object) [const char \*encoding, char \*\*buffer, int \*buffer_length]
    108113   This variant on ``s#`` is used for encoding Unicode and objects convertible
    109114   to Unicode into a character buffer.  Unlike the ``es`` format, this variant
     
    111116
    112117   It requires three arguments.  The first is only used as input, and must be
    113    a :ctype:`const char\*` which points to the name of an encoding as a
     118   a :c:type:`const char\*` which points to the name of an encoding as a
    114119   NUL-terminated string, or *NULL*, in which case the default encoding is
    115120   used.  An exception is raised if the named encoding is not known to Python.
    116    The second argument must be a :ctype:`char\*\*`; the value of the pointer
     121   The second argument must be a :c:type:`char\*\*`; the value of the pointer
    117122   it references will be set to a buffer with the contents of the argument
    118123   text.  The text will be encoded in the encoding specified by the first
     
    125130   of the needed size, copy the encoded data into this buffer and set
    126131   *\*buffer* to reference the newly allocated storage.  The caller is
    127    responsible for calling :cfunc:`PyMem_Free` to free the allocated buffer
     132   responsible for calling :c:func:`PyMem_Free` to free the allocated buffer
    128133   after usage.
    129134
    130135   If *\*buffer* points to a non-*NULL* pointer (an already allocated buffer),
    131    :cfunc:`PyArg_ParseTuple` will use this location as the buffer and
     136   :c:func:`PyArg_ParseTuple` will use this location as the buffer and
    132137   interpret the initial value of *\*buffer_length* as the buffer size.  It
    133138   will then copy the encoded data into the buffer and NUL-terminate it.  If
     
    137142   without the trailing NUL byte.
    138143
    139 ``et#`` (string, Unicode object or character buffer compatible object) [const char \*encoding, char \*\*buffer, int \*buffer_length]
     144``et#`` (string, Unicode or character buffer compatible object) [const char \*encoding, char \*\*buffer, int \*buffer_length]
    140145   Same as ``es#`` except that string objects are passed through without
    141146   recoding them. Instead, the implementation assumes that the string object
     
    144149``b`` (integer) [unsigned char]
    145150   Convert a nonnegative Python integer to an unsigned tiny int, stored in a C
    146    :ctype:`unsigned char`.
     151   :c:type:`unsigned char`.
    147152
    148153``B`` (integer) [unsigned char]
    149154   Convert a Python integer to a tiny int without overflow checking, stored in
    150    a C :ctype:`unsigned char`.
     155   a C :c:type:`unsigned char`.
    151156
    152157   .. versionadded:: 2.3
    153158
    154159``h`` (integer) [short int]
    155    Convert a Python integer to a C :ctype:`short int`.
     160   Convert a Python integer to a C :c:type:`short int`.
    156161
    157162``H`` (integer) [unsigned short int]
    158    Convert a Python integer to a C :ctype:`unsigned short int`, without
     163   Convert a Python integer to a C :c:type:`unsigned short int`, without
    159164   overflow checking.
    160165
     
    162167
    163168``i`` (integer) [int]
    164    Convert a Python integer to a plain C :ctype:`int`.
     169   Convert a Python integer to a plain C :c:type:`int`.
    165170
    166171``I`` (integer) [unsigned int]
    167    Convert a Python integer to a C :ctype:`unsigned int`, without overflow
     172   Convert a Python integer to a C :c:type:`unsigned int`, without overflow
    168173   checking.
    169174
     
    171176
    172177``l`` (integer) [long int]
    173    Convert a Python integer to a C :ctype:`long int`.
     178   Convert a Python integer to a C :c:type:`long int`.
    174179
    175180``k`` (integer) [unsigned long]
    176    Convert a Python integer or long integer to a C :ctype:`unsigned long`
     181   Convert a Python integer or long integer to a C :c:type:`unsigned long`
    177182   without overflow checking.
    178183
     
    180185
    181186``L`` (integer) [PY_LONG_LONG]
    182    Convert a Python integer to a C :ctype:`long long`.  This format is only
    183    available on platforms that support :ctype:`long long` (or :ctype:`_int64`
     187   Convert a Python integer to a C :c:type:`long long`.  This format is only
     188   available on platforms that support :c:type:`long long` (or :c:type:`_int64`
    184189   on Windows).
    185190
    186191``K`` (integer) [unsigned PY_LONG_LONG]
    187    Convert a Python integer or long integer to a C :ctype:`unsigned long long`
     192   Convert a Python integer or long integer to a C :c:type:`unsigned long long`
    188193   without overflow checking.  This format is only available on platforms that
    189    support :ctype:`unsigned long long` (or :ctype:`unsigned _int64` on
     194   support :c:type:`unsigned long long` (or :c:type:`unsigned _int64` on
    190195   Windows).
    191196
     
    193198
    194199``n`` (integer) [Py_ssize_t]
    195    Convert a Python integer or long integer to a C :ctype:`Py_ssize_t`.
     200   Convert a Python integer or long integer to a C :c:type:`Py_ssize_t`.
    196201
    197202   .. versionadded:: 2.5
     
    199204``c`` (string of length 1) [char]
    200205   Convert a Python character, represented as a string of length 1, to a C
    201    :ctype:`char`.
     206   :c:type:`char`.
    202207
    203208``f`` (float) [float]
    204    Convert a Python floating point number to a C :ctype:`float`.
     209   Convert a Python floating point number to a C :c:type:`float`.
    205210
    206211``d`` (float) [double]
    207    Convert a Python floating point number to a C :ctype:`double`.
     212   Convert a Python floating point number to a C :c:type:`double`.
    208213
    209214``D`` (complex) [Py_complex]
    210    Convert a Python complex number to a C :ctype:`Py_complex` structure.
     215   Convert a Python complex number to a C :c:type:`Py_complex` structure.
    211216
    212217``O`` (object) [PyObject \*]
     
    218223   Store a Python object in a C object pointer.  This is similar to ``O``, but
    219224   takes two C arguments: the first is the address of a Python type object,
    220    the second is the address of the C variable (of type :ctype:`PyObject\*`)
     225   the second is the address of the C variable (of type :c:type:`PyObject\*`)
    221226   into which the object pointer is stored.  If the Python object does not
    222227   have the required type, :exc:`TypeError` is raised.
     
    225230   Convert a Python object to a C variable through a *converter* function.
    226231   This takes two arguments: the first is a function, the second is the
    227    address of a C variable (of arbitrary type), converted to :ctype:`void \*`.
     232   address of a C variable (of arbitrary type), converted to :c:type:`void \*`.
    228233   The *converter* function in turn is called as follows::
    229234
     
    231236
    232237   where *object* is the Python object to be converted and *address* is the
    233    :ctype:`void\*` argument that was passed to the :cfunc:`PyArg_Parse\*`
     238   :c:type:`void\*` argument that was passed to the :c:func:`PyArg_Parse\*`
    234239   function.  The returned *status* should be ``1`` for a successful
    235240   conversion and ``0`` if the conversion has failed.  When the conversion
     
    240245   Like ``O`` but requires that the Python object is a string object.  Raises
    241246   :exc:`TypeError` if the object is not a string object.  The C variable may
    242    also be declared as :ctype:`PyObject\*`.
     247   also be declared as :c:type:`PyObject\*`.
    243248
    244249``U`` (Unicode string) [PyUnicodeObject \*]
    245250   Like ``O`` but requires that the Python object is a Unicode object.  Raises
    246251   :exc:`TypeError` if the object is not a Unicode object.  The C variable may
    247    also be declared as :ctype:`PyObject\*`.
     252   also be declared as :c:type:`PyObject\*`.
    248253
    249254``t#`` (read-only character buffer) [char \*, int]
    250255   Like ``s#``, but accepts any object which implements the read-only buffer
    251    interface.  The :ctype:`char\*` variable is set to point to the first byte
    252    of the buffer, and the :ctype:`int` is set to the length of the buffer.
     256   interface.  The :c:type:`char\*` variable is set to point to the first byte
     257   of the buffer, and the :c:type:`int` is set to the length of the buffer.
    253258   Only single-segment buffer objects are accepted; :exc:`TypeError` is raised
    254259   for all others.
     
    262267``w#`` (read-write character buffer) [char \*, Py_ssize_t]
    263268   Like ``s#``, but accepts any object which implements the read-write buffer
    264    interface.  The :ctype:`char \*` variable is set to point to the first byte
    265    of the buffer, and the :ctype:`Py_ssize_t` is set to the length of the
     269   interface.  The :c:type:`char \*` variable is set to point to the first byte
     270   of the buffer, and the :c:type:`Py_ssize_t` is set to the length of the
    266271   buffer.  Only single-segment buffer objects are accepted; :exc:`TypeError`
    267272   is raised for all others.
     
    298303   optional.  The C variables corresponding to optional arguments should be
    299304   initialized to their default value --- when an optional argument is not
    300    specified, :cfunc:`PyArg_ParseTuple` does not touch the contents of the
     305   specified, :c:func:`PyArg_ParseTuple` does not touch the contents of the
    301306   corresponding C variable(s).
    302307
     
    304309   The list of format units ends here; the string after the colon is used as
    305310   the function name in error messages (the "associated value" of the
    306    exception that :cfunc:`PyArg_ParseTuple` raises).
     311   exception that :c:func:`PyArg_ParseTuple` raises).
    307312
    308313``;``
     
    321326
    322327For the conversion to succeed, the *arg* object must match the format and the
    323 format must be exhausted.  On success, the :cfunc:`PyArg_Parse\*` functions
     328format must be exhausted.  On success, the :c:func:`PyArg_Parse\*` functions
    324329return true, otherwise they return false and raise an appropriate exception.
    325 When the :cfunc:`PyArg_Parse\*` functions fail due to conversion failure in
     330When the :c:func:`PyArg_Parse\*` functions fail due to conversion failure in
    326331one of the format units, the variables at the addresses corresponding to that
    327332and the following format units are left untouched.
    328333
    329334
    330 .. cfunction:: int PyArg_ParseTuple(PyObject *args, const char *format, ...)
     335.. c:function:: int PyArg_ParseTuple(PyObject *args, const char *format, ...)
    331336
    332337   Parse the parameters of a function that takes only positional parameters
     
    335340
    336341
    337 .. cfunction:: int PyArg_VaParse(PyObject *args, const char *format, va_list vargs)
    338 
    339    Identical to :cfunc:`PyArg_ParseTuple`, except that it accepts a va_list
     342.. c:function:: int PyArg_VaParse(PyObject *args, const char *format, va_list vargs)
     343
     344   Identical to :c:func:`PyArg_ParseTuple`, except that it accepts a va_list
    340345   rather than a variable number of arguments.
    341346
    342347
    343 .. cfunction:: int PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], ...)
     348.. c:function:: int PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], ...)
    344349
    345350   Parse the parameters of a function that takes both positional and keyword
     
    348353
    349354
    350 .. cfunction:: int PyArg_VaParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], va_list vargs)
    351 
    352    Identical to :cfunc:`PyArg_ParseTupleAndKeywords`, except that it accepts a
     355.. c:function:: int PyArg_VaParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], va_list vargs)
     356
     357   Identical to :c:func:`PyArg_ParseTupleAndKeywords`, except that it accepts a
    353358   va_list rather than a variable number of arguments.
    354359
    355360
    356 .. cfunction:: int PyArg_Parse(PyObject *args, const char *format, ...)
     361.. c:function:: int PyArg_Parse(PyObject *args, const char *format, ...)
    357362
    358363   Function used to deconstruct the argument lists of "old-style" functions
     
    365370
    366371
    367 .. cfunction:: int PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...)
     372.. c:function:: int PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...)
    368373
    369374   A simpler form of parameter retrieval which does not use a format string to
     
    374379   tuple must be at least *min* and no more than *max*; *min* and *max* may be
    375380   equal.  Additional arguments must be passed to the function, each of which
    376    should be a pointer to a :ctype:`PyObject\*` variable; these will be filled
     381   should be a pointer to a :c:type:`PyObject\*` variable; these will be filled
    377382   in with the values from *args*; they will contain borrowed references.  The
    378383   variables which correspond to optional parameters not given by *args* will
     
    397402      }
    398403
    399    The call to :cfunc:`PyArg_UnpackTuple` in this example is entirely
    400    equivalent to this call to :cfunc:`PyArg_ParseTuple`::
     404   The call to :c:func:`PyArg_UnpackTuple` in this example is entirely
     405   equivalent to this call to :c:func:`PyArg_ParseTuple`::
    401406
    402407      PyArg_ParseTuple(args, "O|O:ref", &object, &callback)
     
    405410
    406411   .. versionchanged:: 2.5
    407       This function used an :ctype:`int` type for *min* and *max*. This might
     412      This function used an :c:type:`int` type for *min* and *max*. This might
    408413      require changes in your code for properly supporting 64-bit systems.
    409414
    410415
    411 .. cfunction:: PyObject* Py_BuildValue(const char *format, ...)
     416.. c:function:: PyObject* Py_BuildValue(const char *format, ...)
    412417
    413418   Create a new value based on a format string similar to those accepted by
    414    the :cfunc:`PyArg_Parse\*` family of functions and a sequence of values.
     419   the :c:func:`PyArg_Parse\*` family of functions and a sequence of values.
    415420   Returns the value or *NULL* in the case of an error; an exception will be
    416421   raised if *NULL* is returned.
    417422
    418    :cfunc:`Py_BuildValue` does not always build a tuple.  It builds a tuple
     423   :c:func:`Py_BuildValue` does not always build a tuple.  It builds a tuple
    419424   only if its format string contains two or more format units.  If the format
    420425   string is empty, it returns ``None``; if it contains exactly one format
     
    426431   objects, as for the ``s`` and ``s#`` formats, the required data is copied.
    427432   Buffers provided by the caller are never referenced by the objects created
    428    by :cfunc:`Py_BuildValue`.  In other words, if your code invokes
    429    :cfunc:`malloc` and passes the allocated memory to :cfunc:`Py_BuildValue`,
    430    your code is responsible for calling :cfunc:`free` for that memory once
    431    :cfunc:`Py_BuildValue` returns.
     433   by :c:func:`Py_BuildValue`.  In other words, if your code invokes
     434   :c:func:`malloc` and passes the allocated memory to :c:func:`Py_BuildValue`,
     435   your code is responsible for calling :c:func:`free` for that memory once
     436   :c:func:`Py_BuildValue` returns.
    432437
    433438   In the following description, the quoted form is the format unit; the entry
     
    465470
    466471   ``i`` (integer) [int]
    467       Convert a plain C :ctype:`int` to a Python integer object.
     472      Convert a plain C :c:type:`int` to a Python integer object.
    468473
    469474   ``b`` (integer) [char]
    470       Convert a plain C :ctype:`char` to a Python integer object.
     475      Convert a plain C :c:type:`char` to a Python integer object.
    471476
    472477   ``h`` (integer) [short int]
    473       Convert a plain C :ctype:`short int` to a Python integer object.
     478      Convert a plain C :c:type:`short int` to a Python integer object.
    474479
    475480   ``l`` (integer) [long int]
    476       Convert a C :ctype:`long int` to a Python integer object.
     481      Convert a C :c:type:`long int` to a Python integer object.
    477482
    478483   ``B`` (integer) [unsigned char]
    479       Convert a C :ctype:`unsigned char` to a Python integer object.
     484      Convert a C :c:type:`unsigned char` to a Python integer object.
    480485
    481486   ``H`` (integer) [unsigned short int]
    482       Convert a C :ctype:`unsigned short int` to a Python integer object.
     487      Convert a C :c:type:`unsigned short int` to a Python integer object.
    483488
    484489   ``I`` (integer/long) [unsigned int]
    485       Convert a C :ctype:`unsigned int` to a Python integer object or a Python
     490      Convert a C :c:type:`unsigned int` to a Python integer object or a Python
    486491      long integer object, if it is larger than ``sys.maxint``.
    487492
    488493   ``k`` (integer/long) [unsigned long]
    489       Convert a C :ctype:`unsigned long` to a Python integer object or a
     494      Convert a C :c:type:`unsigned long` to a Python integer object or a
    490495      Python long integer object, if it is larger than ``sys.maxint``.
    491496
    492497   ``L`` (long) [PY_LONG_LONG]
    493       Convert a C :ctype:`long long` to a Python long integer object. Only
    494       available on platforms that support :ctype:`long long`.
     498      Convert a C :c:type:`long long` to a Python long integer object. Only
     499      available on platforms that support :c:type:`long long`.
    495500
    496501   ``K`` (long) [unsigned PY_LONG_LONG]
    497       Convert a C :ctype:`unsigned long long` to a Python long integer object.
    498       Only available on platforms that support :ctype:`unsigned long long`.
     502      Convert a C :c:type:`unsigned long long` to a Python long integer object.
     503      Only available on platforms that support :c:type:`unsigned long long`.
    499504
    500505   ``n`` (int) [Py_ssize_t]
    501       Convert a C :ctype:`Py_ssize_t` to a Python integer or long integer.
     506      Convert a C :c:type:`Py_ssize_t` to a Python integer or long integer.
    502507
    503508      .. versionadded:: 2.5
    504509
    505510   ``c`` (string of length 1) [char]
    506       Convert a C :ctype:`int` representing a character to a Python string of
     511      Convert a C :c:type:`int` representing a character to a Python string of
    507512      length 1.
    508513
    509514   ``d`` (float) [double]
    510       Convert a C :ctype:`double` to a Python floating point number.
     515      Convert a C :c:type:`double` to a Python floating point number.
    511516
    512517   ``f`` (float) [float]
     
    514519
    515520   ``D`` (complex) [Py_complex \*]
    516       Convert a C :ctype:`Py_complex` structure to a Python complex number.
     521      Convert a C :c:type:`Py_complex` structure to a Python complex number.
    517522
    518523   ``O`` (object) [PyObject \*]
     
    520525      incremented by one).  If the object passed in is a *NULL* pointer, it is
    521526      assumed that this was caused because the call producing the argument
    522       found an error and set an exception. Therefore, :cfunc:`Py_BuildValue`
     527      found an error and set an exception. Therefore, :c:func:`Py_BuildValue`
    523528      will return *NULL* but won't raise an exception.  If no exception has
    524529      been raised yet, :exc:`SystemError` is set.
     
    535540      Convert *anything* to a Python object through a *converter* function.
    536541      The function is called with *anything* (which should be compatible with
    537       :ctype:`void \*`) as its argument and should return a "new" Python
     542      :c:type:`void \*`) as its argument and should return a "new" Python
    538543      object, or *NULL* if an error occurred.
    539544
     
    554559   is set and *NULL* returned.
    555560
    556 .. cfunction:: PyObject* Py_VaBuildValue(const char *format, va_list vargs)
    557 
    558    Identical to :cfunc:`Py_BuildValue`, except that it accepts a va_list
     561.. c:function:: PyObject* Py_VaBuildValue(const char *format, va_list vargs)
     562
     563   Identical to :c:func:`Py_BuildValue`, except that it accepts a va_list
    559564   rather than a variable number of arguments.
  • python/vendor/current/Doc/c-api/bool.rst

    r2 r388  
    1212
    1313
    14 .. cfunction:: int PyBool_Check(PyObject *o)
     14.. c:function:: int PyBool_Check(PyObject *o)
    1515
    16    Return true if *o* is of type :cdata:`PyBool_Type`.
     16   Return true if *o* is of type :c:data:`PyBool_Type`.
    1717
    1818   .. versionadded:: 2.3
    1919
    2020
    21 .. cvar:: PyObject* Py_False
     21.. c:var:: PyObject* Py_False
    2222
    2323   The Python ``False`` object.  This object has no methods.  It needs to be
     
    2525
    2626
    27 .. cvar:: PyObject* Py_True
     27.. c:var:: PyObject* Py_True
    2828
    2929   The Python ``True`` object.  This object has no methods.  It needs to be treated
     
    3131
    3232
    33 .. cmacro:: Py_RETURN_FALSE
     33.. c:macro:: Py_RETURN_FALSE
    3434
    3535   Return :const:`Py_False` from a function, properly incrementing its reference
     
    3939
    4040
    41 .. cmacro:: Py_RETURN_TRUE
     41.. c:macro:: Py_RETURN_TRUE
    4242
    4343   Return :const:`Py_True` from a function, properly incrementing its reference
     
    4747
    4848
    49 .. cfunction:: PyObject* PyBool_FromLong(long v)
     49.. c:function:: PyObject* PyBool_FromLong(long v)
    5050
    5151   Return a new reference to :const:`Py_True` or :const:`Py_False` depending on the
  • python/vendor/current/Doc/c-api/buffer.rst

    r2 r388  
    33.. _bufferobjects:
    44
    5 Buffer Objects
    6 --------------
     5Buffers and Memoryview Objects
     6------------------------------
    77
    88.. sectionauthor:: Greg Stein <gstein@lyra.org>
     9.. sectionauthor:: Benjamin Peterson
    910
    1011
     
    2728method. Any object that can export a series of bytes through the buffer
    2829interface can be written to a file. There are a number of format codes to
    29 :cfunc:`PyArg_ParseTuple` that operate against an object's buffer interface,
     30:c:func:`PyArg_ParseTuple` that operate against an object's buffer interface,
    3031returning data from the target object.
    3132
     
    3334objects and a C-level buffer API so that any built-in or used-defined type can
    3435expose its characteristics. Both, however, have been deprecated because of
    35 various shortcomings, and have been officially removed in Python 3.0 in favour
     36various shortcomings, and have been officially removed in Python 3 in favour
    3637of a new C-level buffer API and a new Python-level object named
    3738:class:`memoryview`.
     
    4748
    4849
    49 .. ctype:: Py_buffer
    50 
    51    .. cmember:: void *buf
     50.. c:type:: Py_buffer
     51
     52   .. c:member:: void *buf
    5253
    5354      A pointer to the start of the memory for the object.
    5455
    55    .. cmember:: Py_ssize_t len
     56   .. c:member:: Py_ssize_t len
    5657      :noindex:
    5758
    5859      The total length of the memory in bytes.
    5960
    60    .. cmember:: int readonly
     61   .. c:member:: int readonly
    6162
    6263      An indicator of whether the buffer is read only.
    6364
    64    .. cmember:: const char *format
     65   .. c:member:: const char *format
    6566      :noindex:
    6667
     
    6970      *NULL*, ``"B"`` (unsigned bytes) is assumed.
    7071
    71    .. cmember:: int ndim
     72   .. c:member:: int ndim
    7273
    7374      The number of dimensions the memory represents as a multi-dimensional
    74       array.  If it is 0, :cdata:`strides` and :cdata:`suboffsets` must be
     75      array.  If it is 0, :c:data:`strides` and :c:data:`suboffsets` must be
    7576      *NULL*.
    7677
    77    .. cmember:: Py_ssize_t *shape
    78 
    79       An array of :ctype:`Py_ssize_t`\s the length of :cdata:`ndim` giving the
     78   .. c:member:: Py_ssize_t *shape
     79
     80      An array of :c:type:`Py_ssize_t`\s the length of :c:data:`ndim` giving the
    8081      shape of the memory as a multi-dimensional array.  Note that
    8182      ``((*shape)[0] * ... * (*shape)[ndims-1])*itemsize`` should be equal to
    82       :cdata:`len`.
    83 
    84    .. cmember:: Py_ssize_t *strides
    85 
    86       An array of :ctype:`Py_ssize_t`\s the length of :cdata:`ndim` giving the
     83      :c:data:`len`.
     84
     85   .. c:member:: Py_ssize_t *strides
     86
     87      An array of :c:type:`Py_ssize_t`\s the length of :c:data:`ndim` giving the
    8788      number of bytes to skip to get to a new element in each dimension.
    8889
    89    .. cmember:: Py_ssize_t *suboffsets
    90 
    91       An array of :ctype:`Py_ssize_t`\s the length of :cdata:`ndim`.  If these
     90   .. c:member:: Py_ssize_t *suboffsets
     91
     92      An array of :c:type:`Py_ssize_t`\s the length of :c:data:`ndim`.  If these
    9293      suboffset numbers are greater than or equal to 0, then the value stored
    9394      along the indicated dimension is a pointer and the suboffset value
     
    114115
    115116
    116    .. cmember:: Py_ssize_t itemsize
     117   .. c:member:: Py_ssize_t itemsize
    117118
    118119      This is a storage for the itemsize (in bytes) of each element of the
    119120      shared memory. It is technically un-necessary as it can be obtained
    120       using :cfunc:`PyBuffer_SizeFromFormat`, however an exporter may know
     121      using :c:func:`PyBuffer_SizeFromFormat`, however an exporter may know
    121122      this information without parsing the format string and it is necessary
    122123      to know the itemsize for proper interpretation of striding. Therefore,
    123124      storing it is more convenient and faster.
    124125
    125    .. cmember:: void *internal
     126   .. c:member:: void *internal
    126127
    127128      This is for use internally by the exporting object. For example, this
     
    136137
    137138
    138 .. cfunction:: int PyObject_CheckBuffer(PyObject *obj)
     139.. c:function:: int PyObject_CheckBuffer(PyObject *obj)
    139140
    140141   Return 1 if *obj* supports the buffer interface otherwise 0.
    141142
    142143
    143 .. cfunction:: int PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags)
    144 
    145       Export *obj* into a :ctype:`Py_buffer`, *view*.  These arguments must
     144.. c:function:: int PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags)
     145
     146      Export *obj* into a :c:type:`Py_buffer`, *view*.  These arguments must
    146147      never be *NULL*.  The *flags* argument is a bit field indicating what
    147148      kind of buffer the caller is prepared to deal with and therefore what
     
    156157      there is another error that is actually causing the problem. The
    157158      exporter can use flags information to simplify how much of the
    158       :cdata:`Py_buffer` structure is filled in with non-default values and/or
     159      :c:data:`Py_buffer` structure is filled in with non-default values and/or
    159160      raise an error if the object can't support a simpler view of its memory.
    160161
     
    163164      The following table gives possible values to the *flags* arguments.
    164165
    165       +------------------------------+---------------------------------------------------+
    166       | Flag                         | Description                                       |
    167       +==============================+===================================================+
    168       | :cmacro:`PyBUF_SIMPLE`       | This is the default flag state.  The returned     |
    169       |                              | buffer may or may not have writable memory.  The  |
    170       |                              | format of the data will be assumed to be unsigned |
    171       |                              | bytes.  This is a "stand-alone" flag constant. It |
    172       |                              | never needs to be '|'d to the others. The exporter|
    173       |                              | will raise an error if it cannot provide such a   |
    174       |                              | contiguous buffer of bytes.                       |
    175       |                              |                                                   |
    176       +------------------------------+---------------------------------------------------+
    177       | :cmacro:`PyBUF_WRITABLE`     | The returned buffer must be writable.  If it is   |
    178       |                              | not writable, then raise an error.                |
    179       +------------------------------+---------------------------------------------------+
    180       | :cmacro:`PyBUF_STRIDES`      | This implies :cmacro:`PyBUF_ND`. The returned     |
    181       |                              | buffer must provide strides information (i.e. the |
    182       |                              | strides cannot be NULL). This would be used when  |
    183       |                              | the consumer can handle strided, discontiguous    |
    184       |                              | arrays.  Handling strides automatically assumes   |
    185       |                              | you can handle shape.  The exporter can raise an  |
    186       |                              | error if a strided representation of the data is  |
    187       |                              | not possible (i.e. without the suboffsets).       |
    188       |                              |                                                   |
    189       +------------------------------+---------------------------------------------------+
    190       | :cmacro:`PyBUF_ND`           | The returned buffer must provide shape            |
    191       |                              | information. The memory will be assumed C-style   |
    192       |                              | contiguous (last dimension varies the             |
    193       |                              | fastest). The exporter may raise an error if it   |
    194       |                              | cannot provide this kind of contiguous buffer. If |
    195       |                              | this is not given then shape will be *NULL*.      |
    196       |                              |                                                   |
    197       |                              |                                                   |
    198       |                              |                                                   |
    199       +------------------------------+---------------------------------------------------+
    200       |:cmacro:`PyBUF_C_CONTIGUOUS`  | These flags indicate that the contiguity returned |
    201       |:cmacro:`PyBUF_F_CONTIGUOUS`  | buffer must be respectively, C-contiguous (last   |
    202       |:cmacro:`PyBUF_ANY_CONTIGUOUS`| dimension varies the fastest), Fortran contiguous |
    203       |                              | (first dimension varies the fastest) or either    |
    204       |                              | one.  All of these flags imply                    |
    205       |                              | :cmacro:`PyBUF_STRIDES` and guarantee that the    |
    206       |                              | strides buffer info structure will be filled in   |
    207       |                              | correctly.                                        |
    208       |                              |                                                   |
    209       +------------------------------+---------------------------------------------------+
    210       | :cmacro:`PyBUF_INDIRECT`     | This flag indicates the returned buffer must have |
    211       |                              | suboffsets information (which can be NULL if no   |
    212       |                              | suboffsets are needed).  This can be used when    |
    213       |                              | the consumer can handle indirect array            |
    214       |                              | referencing implied by these suboffsets. This     |
    215       |                              | implies :cmacro:`PyBUF_STRIDES`.                  |
    216       |                              |                                                   |
    217       |                              |                                                   |
    218       |                              |                                                   |
    219       +------------------------------+---------------------------------------------------+
    220       | :cmacro:`PyBUF_FORMAT`       | The returned buffer must have true format         |
    221       |                              | information if this flag is provided. This would  |
    222       |                              | be used when the consumer is going to be checking |
    223       |                              | for what 'kind' of data is actually stored. An    |
    224       |                              | exporter should always be able to provide this    |
    225       |                              | information if requested. If format is not        |
    226       |                              | explicitly requested then the format must be      |
    227       |                              | returned as *NULL* (which means ``'B'``, or       |
    228       |                              | unsigned bytes)                                   |
    229       +------------------------------+---------------------------------------------------+
    230       | :cmacro:`PyBUF_STRIDED`      | This is equivalent to ``(PyBUF_STRIDES |          |
    231       |                              | PyBUF_WRITABLE)``.                                |
    232       +------------------------------+---------------------------------------------------+
    233       | :cmacro:`PyBUF_STRIDED_RO`   | This is equivalent to ``(PyBUF_STRIDES)``.        |
    234       |                              |                                                   |
    235       +------------------------------+---------------------------------------------------+
    236       | :cmacro:`PyBUF_RECORDS`      | This is equivalent to ``(PyBUF_STRIDES |          |
    237       |                              | PyBUF_FORMAT | PyBUF_WRITABLE)``.                 |
    238       +------------------------------+---------------------------------------------------+
    239       | :cmacro:`PyBUF_RECORDS_RO`   | This is equivalent to ``(PyBUF_STRIDES |          |
    240       |                              | PyBUF_FORMAT)``.                                  |
    241       +------------------------------+---------------------------------------------------+
    242       | :cmacro:`PyBUF_FULL`         | This is equivalent to ``(PyBUF_INDIRECT |         |
    243       |                              | PyBUF_FORMAT | PyBUF_WRITABLE)``.                 |
    244       +------------------------------+---------------------------------------------------+
    245       | :cmacro:`PyBUF_FULL_RO`      | This is equivalent to ``(PyBUF_INDIRECT |         |
    246       |                              | PyBUF_FORMAT)``.                                  |
    247       +------------------------------+---------------------------------------------------+
    248       | :cmacro:`PyBUF_CONTIG`       | This is equivalent to ``(PyBUF_ND |               |
    249       |                              | PyBUF_WRITABLE)``.                                |
    250       +------------------------------+---------------------------------------------------+
    251       | :cmacro:`PyBUF_CONTIG_RO`    | This is equivalent to ``(PyBUF_ND)``.             |
    252       |                              |                                                   |
    253       +------------------------------+---------------------------------------------------+
    254 
    255 
    256 .. cfunction:: void PyBuffer_Release(Py_buffer *view)
     166      +-------------------------------+---------------------------------------------------+
     167      | Flag                          | Description                                       |
     168      +===============================+===================================================+
     169      | :c:macro:`PyBUF_SIMPLE`       | This is the default flag state.  The returned     |
     170      |                               | buffer may or may not have writable memory.  The  |
     171      |                               | format of the data will be assumed to be unsigned |
     172      |                               | bytes.  This is a "stand-alone" flag constant. It |
     173      |                               | never needs to be '|'d to the others. The exporter|
     174      |                               | will raise an error if it cannot provide such a   |
     175      |                               | contiguous buffer of bytes.                       |
     176      |                               |                                                   |
     177      +-------------------------------+---------------------------------------------------+
     178      | :c:macro:`PyBUF_WRITABLE`     | The returned buffer must be writable.  If it is   |
     179      |                               | not writable, then raise an error.                |
     180      +-------------------------------+---------------------------------------------------+
     181      | :c:macro:`PyBUF_STRIDES`      | This implies :c:macro:`PyBUF_ND`. The returned    |
     182      |                               | buffer must provide strides information (i.e. the |
     183      |                               | strides cannot be NULL). This would be used when  |
     184      |                               | the consumer can handle strided, discontiguous    |
     185      |                               | arrays.  Handling strides automatically assumes   |
     186      |                               | you can handle shape.  The exporter can raise an  |
     187      |                               | error if a strided representation of the data is  |
     188      |                               | not possible (i.e. without the suboffsets).       |
     189      |                               |                                                   |
     190      +-------------------------------+---------------------------------------------------+
     191      | :c:macro:`PyBUF_ND`           | The returned buffer must provide shape            |
     192      |                               | information. The memory will be assumed C-style   |
     193      |                               | contiguous (last dimension varies the             |
     194      |                               | fastest). The exporter may raise an error if it   |
     195      |                               | cannot provide this kind of contiguous buffer. If |
     196      |                               | this is not given then shape will be *NULL*.      |
     197      |                               |                                                   |
     198      |                               |                                                   |
     199      |                               |                                                   |
     200      +-------------------------------+---------------------------------------------------+
     201      |:c:macro:`PyBUF_C_CONTIGUOUS`  | These flags indicate that the contiguity returned |
     202      |:c:macro:`PyBUF_F_CONTIGUOUS`  | buffer must be respectively, C-contiguous (last   |
     203      |:c:macro:`PyBUF_ANY_CONTIGUOUS`| dimension varies the fastest), Fortran contiguous |
     204      |                               | (first dimension varies the fastest) or either    |
     205      |                               | one.  All of these flags imply                    |
     206      |                               | :c:macro:`PyBUF_STRIDES` and guarantee that the   |
     207      |                               | strides buffer info structure will be filled in   |
     208      |                               | correctly.                                        |
     209      |                               |                                                   |
     210      +-------------------------------+---------------------------------------------------+
     211      | :c:macro:`PyBUF_INDIRECT`     | This flag indicates the returned buffer must have |
     212      |                               | suboffsets information (which can be NULL if no   |
     213      |                               | suboffsets are needed).  This can be used when    |
     214      |                               | the consumer can handle indirect array            |
     215      |                               | referencing implied by these suboffsets. This     |
     216      |                               | implies :c:macro:`PyBUF_STRIDES`.                 |
     217      |                               |                                                   |
     218      |                               |                                                   |
     219      |                               |                                                   |
     220      +-------------------------------+---------------------------------------------------+
     221      | :c:macro:`PyBUF_FORMAT`       | The returned buffer must have true format         |
     222      |                               | information if this flag is provided. This would  |
     223      |                               | be used when the consumer is going to be checking |
     224      |                               | for what 'kind' of data is actually stored. An    |
     225      |                               | exporter should always be able to provide this    |
     226      |                               | information if requested. If format is not        |
     227      |                               | explicitly requested then the format must be      |
     228      |                               | returned as *NULL* (which means ``'B'``, or       |
     229      |                               | unsigned bytes)                                   |
     230      +-------------------------------+---------------------------------------------------+
     231      | :c:macro:`PyBUF_STRIDED`      | This is equivalent to ``(PyBUF_STRIDES |          |
     232      |                               | PyBUF_WRITABLE)``.                                |
     233      +-------------------------------+---------------------------------------------------+
     234      | :c:macro:`PyBUF_STRIDED_RO`   | This is equivalent to ``(PyBUF_STRIDES)``.        |
     235      |                               |                                                   |
     236      +-------------------------------+---------------------------------------------------+
     237      | :c:macro:`PyBUF_RECORDS`      | This is equivalent to ``(PyBUF_STRIDES |          |
     238      |                               | PyBUF_FORMAT | PyBUF_WRITABLE)``.                 |
     239      +-------------------------------+---------------------------------------------------+
     240      | :c:macro:`PyBUF_RECORDS_RO`   | This is equivalent to ``(PyBUF_STRIDES |          |
     241      |                               | PyBUF_FORMAT)``.                                  |
     242      +-------------------------------+---------------------------------------------------+
     243      | :c:macro:`PyBUF_FULL`         | This is equivalent to ``(PyBUF_INDIRECT |         |
     244      |                               | PyBUF_FORMAT | PyBUF_WRITABLE)``.                 |
     245      +-------------------------------+---------------------------------------------------+
     246      | :c:macro:`PyBUF_FULL_RO`      | This is equivalent to ``(PyBUF_INDIRECT |         |
     247      |                               | PyBUF_FORMAT)``.                                  |
     248      +-------------------------------+---------------------------------------------------+
     249      | :c:macro:`PyBUF_CONTIG`       | This is equivalent to ``(PyBUF_ND |               |
     250      |                               | PyBUF_WRITABLE)``.                                |
     251      +-------------------------------+---------------------------------------------------+
     252      | :c:macro:`PyBUF_CONTIG_RO`    | This is equivalent to ``(PyBUF_ND)``.             |
     253      |                               |                                                   |
     254      +-------------------------------+---------------------------------------------------+
     255
     256
     257.. c:function:: void PyBuffer_Release(Py_buffer *view)
    257258
    258259   Release the buffer *view*.  This should be called when the buffer
     
    260261
    261262
    262 .. cfunction:: Py_ssize_t PyBuffer_SizeFromFormat(const char *)
    263 
    264    Return the implied :cdata:`~Py_buffer.itemsize` from the struct-stype
    265    :cdata:`~Py_buffer.format`.
    266 
    267 
    268 .. cfunction:: int PyObject_CopyToObject(PyObject *obj, void *buf, Py_ssize_t len, char fortran)
    269 
    270    Copy *len* bytes of data pointed to by the contiguous chunk of memory
    271    pointed to by *buf* into the buffer exported by obj.  The buffer must of
    272    course be writable.  Return 0 on success and return -1 and raise an error
    273    on failure.  If the object does not have a writable buffer, then an error
    274    is raised.  If *fortran* is ``'F'``, then if the object is
    275    multi-dimensional, then the data will be copied into the array in
    276    Fortran-style (first dimension varies the fastest).  If *fortran* is
    277    ``'C'``, then the data will be copied into the array in C-style (last
    278    dimension varies the fastest).  If *fortran* is ``'A'``, then it does not
    279    matter and the copy will be made in whatever way is more efficient.
    280 
    281 
    282 .. cfunction:: int PyBuffer_IsContiguous(Py_buffer *view, char fortran)
     263.. c:function:: Py_ssize_t PyBuffer_SizeFromFormat(const char *)
     264
     265   Return the implied :c:data:`~Py_buffer.itemsize` from the struct-stype
     266   :c:data:`~Py_buffer.format`.
     267
     268
     269.. c:function:: int PyBuffer_IsContiguous(Py_buffer *view, char fortran)
    283270
    284271   Return 1 if the memory defined by the *view* is C-style (*fortran* is
     
    287274
    288275
    289 .. cfunction:: void PyBuffer_FillContiguousStrides(int ndim, Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t itemsize, char fortran)
     276.. c:function:: void PyBuffer_FillContiguousStrides(int ndim, Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t itemsize, char fortran)
    290277
    291278   Fill the *strides* array with byte-strides of a contiguous (C-style if
    292    *fortran* is ``'C'`` or Fortran-style if *fortran* is ``'F'`` array of the
     279   *fortran* is ``'C'`` or Fortran-style if *fortran* is ``'F'``) array of the
    293280   given shape with the given number of bytes per element.
    294281
    295282
    296 .. cfunction:: int PyBuffer_FillInfo(Py_buffer *view, void *buf, Py_ssize_t len, int readonly, int infoflags)
     283.. c:function:: int PyBuffer_FillInfo(Py_buffer *view, PyObject *obj, void *buf, Py_ssize_t len, int readonly, int infoflags)
    297284
    298285   Fill in a buffer-info structure, *view*, correctly for an exporter that can
     
    301288
    302289
     290MemoryView objects
     291==================
     292
     293.. versionadded:: 2.7
     294
     295A :class:`memoryview` object exposes the new C level buffer interface as a
     296Python object which can then be passed around like any other object.
     297
     298.. c:function:: PyObject *PyMemoryView_FromObject(PyObject *obj)
     299
     300   Create a memoryview object from an object that defines the new buffer
     301   interface.
     302
     303
     304.. c:function:: PyObject *PyMemoryView_FromBuffer(Py_buffer *view)
     305
     306   Create a memoryview object wrapping the given buffer-info structure *view*.
     307   The memoryview object then owns the buffer, which means you shouldn't
     308   try to release it yourself: it will be released on deallocation of the
     309   memoryview object.
     310
     311
     312.. c:function:: PyObject *PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char order)
     313
     314   Create a memoryview object to a contiguous chunk of memory (in either
     315   'C' or 'F'ortran *order*) from an object that defines the buffer
     316   interface. If memory is contiguous, the memoryview object points to the
     317   original memory. Otherwise copy is made and the memoryview points to a
     318   new bytes object.
     319
     320
     321.. c:function:: int PyMemoryView_Check(PyObject *obj)
     322
     323   Return true if the object *obj* is a memoryview object.  It is not
     324   currently allowed to create subclasses of :class:`memoryview`.
     325
     326
     327.. c:function:: Py_buffer *PyMemoryView_GET_BUFFER(PyObject *obj)
     328
     329   Return a pointer to the buffer-info structure wrapped by the given
     330   object.  The object **must** be a memoryview instance; this macro doesn't
     331   check its type, you must do it yourself or you will risk crashes.
     332
     333
    303334Old-style buffer objects
    304335========================
     
    306337.. index:: single: PyBufferProcs
    307338
    308 More information on the buffer interface is provided in the section
    309 :ref:`buffer-structs`, under the description for :ctype:`PyBufferProcs`.
     339More information on the old buffer interface is provided in the section
     340:ref:`buffer-structs`, under the description for :c:type:`PyBufferProcs`.
    310341
    311342A "buffer object" is defined in the :file:`bufferobject.h` header (included by
     
    326357
    327358
    328 .. ctype:: PyBufferObject
    329 
    330    This subtype of :ctype:`PyObject` represents a buffer object.
    331 
    332 
    333 .. cvar:: PyTypeObject PyBuffer_Type
     359.. c:type:: PyBufferObject
     360
     361   This subtype of :c:type:`PyObject` represents a buffer object.
     362
     363
     364.. c:var:: PyTypeObject PyBuffer_Type
    334365
    335366   .. index:: single: BufferType (in module types)
    336367
    337    The instance of :ctype:`PyTypeObject` which represents the Python buffer type;
     368   The instance of :c:type:`PyTypeObject` which represents the Python buffer type;
    338369   it is the same object as ``buffer`` and  ``types.BufferType`` in the Python
    339370   layer. .
    340371
    341372
    342 .. cvar:: int Py_END_OF_BUFFER
     373.. c:var:: int Py_END_OF_BUFFER
    343374
    344375   This constant may be passed as the *size* parameter to
    345    :cfunc:`PyBuffer_FromObject` or :cfunc:`PyBuffer_FromReadWriteObject`.  It
    346    indicates that the new :ctype:`PyBufferObject` should refer to *base*
     376   :c:func:`PyBuffer_FromObject` or :c:func:`PyBuffer_FromReadWriteObject`.  It
     377   indicates that the new :c:type:`PyBufferObject` should refer to *base*
    347378   object from the specified *offset* to the end of its exported buffer.
    348379   Using this enables the caller to avoid querying the *base* object for its
     
    350381
    351382
    352 .. cfunction:: int PyBuffer_Check(PyObject *p)
    353 
    354    Return true if the argument has type :cdata:`PyBuffer_Type`.
    355 
    356 
    357 .. cfunction:: PyObject* PyBuffer_FromObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)
     383.. c:function:: int PyBuffer_Check(PyObject *p)
     384
     385   Return true if the argument has type :c:data:`PyBuffer_Type`.
     386
     387
     388.. c:function:: PyObject* PyBuffer_FromObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)
    358389
    359390   Return a new read-only buffer object.  This raises :exc:`TypeError` if
     
    367398
    368399   .. versionchanged:: 2.5
    369       This function used an :ctype:`int` type for *offset* and *size*. This
     400      This function used an :c:type:`int` type for *offset* and *size*. This
    370401      might require changes in your code for properly supporting 64-bit
    371402      systems.
    372403
    373404
    374 .. cfunction:: PyObject* PyBuffer_FromReadWriteObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)
     405.. c:function:: PyObject* PyBuffer_FromReadWriteObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)
    375406
    376407   Return a new writable buffer object.  Parameters and exceptions are similar
    377    to those for :cfunc:`PyBuffer_FromObject`.  If the *base* object does not
     408   to those for :c:func:`PyBuffer_FromObject`.  If the *base* object does not
    378409   export the writeable buffer protocol, then :exc:`TypeError` is raised.
    379410
    380411   .. versionchanged:: 2.5
    381       This function used an :ctype:`int` type for *offset* and *size*. This
     412      This function used an :c:type:`int` type for *offset* and *size*. This
    382413      might require changes in your code for properly supporting 64-bit
    383414      systems.
    384415
    385416
    386 .. cfunction:: PyObject* PyBuffer_FromMemory(void *ptr, Py_ssize_t size)
     417.. c:function:: PyObject* PyBuffer_FromMemory(void *ptr, Py_ssize_t size)
    387418
    388419   Return a new read-only buffer object that reads from a specified location
     
    394425
    395426   .. versionchanged:: 2.5
    396       This function used an :ctype:`int` type for *size*. This might require
     427      This function used an :c:type:`int` type for *size*. This might require
    397428      changes in your code for properly supporting 64-bit systems.
    398429
    399430
    400 .. cfunction:: PyObject* PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size)
    401 
    402    Similar to :cfunc:`PyBuffer_FromMemory`, but the returned buffer is
     431.. c:function:: PyObject* PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size)
     432
     433   Similar to :c:func:`PyBuffer_FromMemory`, but the returned buffer is
    403434   writable.
    404435
    405436   .. versionchanged:: 2.5
    406       This function used an :ctype:`int` type for *size*. This might require
     437      This function used an :c:type:`int` type for *size*. This might require
    407438      changes in your code for properly supporting 64-bit systems.
    408439
    409440
    410 .. cfunction:: PyObject* PyBuffer_New(Py_ssize_t size)
     441.. c:function:: PyObject* PyBuffer_New(Py_ssize_t size)
    411442
    412443   Return a new writable buffer object that maintains its own memory buffer of
    413444   *size* bytes.  :exc:`ValueError` is returned if *size* is not zero or
    414445   positive.  Note that the memory buffer (as returned by
    415    :cfunc:`PyObject_AsWriteBuffer`) is not specifically aligned.
     446   :c:func:`PyObject_AsWriteBuffer`) is not specifically aligned.
    416447
    417448   .. versionchanged:: 2.5
    418       This function used an :ctype:`int` type for *size*. This might require
     449      This function used an :c:type:`int` type for *size*. This might require
    419450      changes in your code for properly supporting 64-bit systems.
  • python/vendor/current/Doc/c-api/bytearray.rst

    r2 r388  
    1111
    1212
    13 .. ctype:: PyByteArrayObject
     13.. c:type:: PyByteArrayObject
    1414
    15    This subtype of :ctype:`PyObject` represents a Python bytearray object.
     15   This subtype of :c:type:`PyObject` represents a Python bytearray object.
    1616
    1717
    18 .. cvar:: PyTypeObject PyByteArray_Type
     18.. c:var:: PyTypeObject PyByteArray_Type
    1919
    20    This instance of :ctype:`PyTypeObject` represents the Python bytearray type;
     20   This instance of :c:type:`PyTypeObject` represents the Python bytearray type;
    2121   it is the same object as ``bytearray`` in the Python layer.
    2222
     
    2424^^^^^^^^^^^^^^^^^
    2525
    26 .. cfunction:: int PyByteArray_Check(PyObject *o)
     26.. c:function:: int PyByteArray_Check(PyObject *o)
    2727
    2828   Return true if the object *o* is a bytearray object or an instance of a
     
    3030
    3131
    32 .. cfunction:: int PyByteArray_CheckExact(PyObject *o)
     32.. c:function:: int PyByteArray_CheckExact(PyObject *o)
    3333
    3434   Return true if the object *o* is a bytearray object, but not an instance of a
     
    3939^^^^^^^^^^^^^^^^^^^^
    4040
    41 .. cfunction:: PyObject* PyByteArray_FromObject(PyObject *o)
     41.. c:function:: PyObject* PyByteArray_FromObject(PyObject *o)
    4242
    4343   Return a new bytearray object from any object, *o*, that implements the
     
    4747
    4848
    49 .. cfunction:: PyObject* PyByteArray_FromStringAndSize(const char *string, Py_ssize_t len)
     49.. c:function:: PyObject* PyByteArray_FromStringAndSize(const char *string, Py_ssize_t len)
    5050
    5151   Create a new bytearray object from *string* and its length, *len*.  On
     
    5353
    5454
    55 .. cfunction:: PyObject* PyByteArray_Concat(PyObject *a, PyObject *b)
     55.. c:function:: PyObject* PyByteArray_Concat(PyObject *a, PyObject *b)
    5656
    5757   Concat bytearrays *a* and *b* and return a new bytearray with the result.
    5858
    5959
    60 .. cfunction:: Py_ssize_t PyByteArray_Size(PyObject *bytearray)
     60.. c:function:: Py_ssize_t PyByteArray_Size(PyObject *bytearray)
    6161
    6262   Return the size of *bytearray* after checking for a *NULL* pointer.
    6363
    6464
    65 .. cfunction:: char* PyByteArray_AsString(PyObject *bytearray)
     65.. c:function:: char* PyByteArray_AsString(PyObject *bytearray)
    6666
    6767   Return the contents of *bytearray* as a char array after checking for a
     
    6969
    7070
    71 .. cfunction:: int PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len)
     71.. c:function:: int PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len)
    7272
    7373   Resize the internal buffer of *bytearray* to *len*.
     
    7878These macros trade safety for speed and they don't check pointers.
    7979
    80 .. cfunction:: char* PyByteArray_AS_STRING(PyObject *bytearray)
     80.. c:function:: char* PyByteArray_AS_STRING(PyObject *bytearray)
    8181
    82    Macro version of :cfunc:`PyByteArray_AsString`.
     82   Macro version of :c:func:`PyByteArray_AsString`.
    8383
    8484
    85 .. cfunction:: Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray)
     85.. c:function:: Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray)
    8686
    87    Macro version of :cfunc:`PyByteArray_Size`.
     87   Macro version of :c:func:`PyByteArray_Size`.
  • python/vendor/current/Doc/c-api/cell.rst

    r2 r388  
    1616
    1717
    18 .. ctype:: PyCellObject
     18.. c:type:: PyCellObject
    1919
    2020   The C structure used for cell objects.
    2121
    2222
    23 .. cvar:: PyTypeObject PyCell_Type
     23.. c:var:: PyTypeObject PyCell_Type
    2424
    2525   The type object corresponding to cell objects.
    2626
    2727
    28 .. cfunction:: int PyCell_Check(ob)
     28.. c:function:: int PyCell_Check(ob)
    2929
    3030   Return true if *ob* is a cell object; *ob* must not be *NULL*.
    3131
    3232
    33 .. cfunction:: PyObject* PyCell_New(PyObject *ob)
     33.. c:function:: PyObject* PyCell_New(PyObject *ob)
    3434
    3535   Create and return a new cell object containing the value *ob*. The parameter may
     
    3737
    3838
    39 .. cfunction:: PyObject* PyCell_Get(PyObject *cell)
     39.. c:function:: PyObject* PyCell_Get(PyObject *cell)
    4040
    4141   Return the contents of the cell *cell*.
    4242
    4343
    44 .. cfunction:: PyObject* PyCell_GET(PyObject *cell)
     44.. c:function:: PyObject* PyCell_GET(PyObject *cell)
    4545
    4646   Return the contents of the cell *cell*, but without checking that *cell* is
     
    4848
    4949
    50 .. cfunction:: int PyCell_Set(PyObject *cell, PyObject *value)
     50.. c:function:: int PyCell_Set(PyObject *cell, PyObject *value)
    5151
    5252   Set the contents of the cell object *cell* to *value*.  This releases the
     
    5656
    5757
    58 .. cfunction:: void PyCell_SET(PyObject *cell, PyObject *value)
     58.. c:function:: void PyCell_SET(PyObject *cell, PyObject *value)
    5959
    6060   Sets the value of the cell object *cell* to *value*.  No reference counts are
  • python/vendor/current/Doc/c-api/class.rst

    r2 r388  
    1313
    1414
    15 .. ctype:: PyClassObject
     15.. c:type:: PyClassObject
    1616
    1717   The C structure of the objects used to describe built-in classes.
    1818
    1919
    20 .. cvar:: PyObject* PyClass_Type
     20.. c:var:: PyObject* PyClass_Type
    2121
    2222   .. index:: single: ClassType (in module types)
     
    2626
    2727
    28 .. cfunction:: int PyClass_Check(PyObject *o)
     28.. c:function:: int PyClass_Check(PyObject *o)
    2929
    3030   Return true if the object *o* is a class object, including instances of types
     
    3232
    3333
    34 .. cfunction:: int PyClass_IsSubclass(PyObject *klass, PyObject *base)
     34.. c:function:: int PyClass_IsSubclass(PyObject *klass, PyObject *base)
    3535
    3636   Return true if *klass* is a subclass of *base*. Return false in all other cases.
     
    4242
    4343
    44 .. cvar:: PyTypeObject PyInstance_Type
     44.. c:var:: PyTypeObject PyInstance_Type
    4545
    4646   Type object for class instances.
    4747
    4848
    49 .. cfunction:: int PyInstance_Check(PyObject *obj)
     49.. c:function:: int PyInstance_Check(PyObject *obj)
    5050
    5151   Return true if *obj* is an instance.
    5252
    5353
    54 .. cfunction:: PyObject* PyInstance_New(PyObject *class, PyObject *arg, PyObject *kw)
     54.. c:function:: PyObject* PyInstance_New(PyObject *class, PyObject *arg, PyObject *kw)
    5555
    5656   Create a new instance of a specific class.  The parameters *arg* and *kw* are
     
    5858
    5959
    60 .. cfunction:: PyObject* PyInstance_NewRaw(PyObject *class, PyObject *dict)
     60.. c:function:: PyObject* PyInstance_NewRaw(PyObject *class, PyObject *dict)
    6161
    6262   Create a new instance of a specific class without calling its constructor.
  • python/vendor/current/Doc/c-api/cobject.rst

    r2 r388  
    88.. index:: object: CObject
    99
    10 Refer to :ref:`using-cobjects` for more information on using these objects.
    1110
     11.. warning::
    1212
    13 .. ctype:: PyCObject
     13   The CObject API is deprecated as of Python 2.7.  Please switch to the new
     14   :ref:`capsules` API.
    1415
    15    This subtype of :ctype:`PyObject` represents an opaque value, useful for C
    16    extension modules who need to pass an opaque value (as a :ctype:`void\*`
     16.. c:type:: PyCObject
     17
     18   This subtype of :c:type:`PyObject` represents an opaque value, useful for C
     19   extension modules who need to pass an opaque value (as a :c:type:`void\*`
    1720   pointer) through Python code to other C code.  It is often used to make a C
    1821   function pointer defined in one module available to other modules, so the
     
    2124
    2225
    23 .. cfunction:: int PyCObject_Check(PyObject *p)
     26.. c:function:: int PyCObject_Check(PyObject *p)
    2427
    25    Return true if its argument is a :ctype:`PyCObject`.
     28   Return true if its argument is a :c:type:`PyCObject`.
    2629
    2730
    28 .. cfunction:: PyObject* PyCObject_FromVoidPtr(void* cobj, void (*destr)(void *))
     31.. c:function:: PyObject* PyCObject_FromVoidPtr(void* cobj, void (*destr)(void *))
    2932
    30    Create a :ctype:`PyCObject` from the ``void *`` *cobj*.  The *destr* function
     33   Create a :c:type:`PyCObject` from the ``void *`` *cobj*.  The *destr* function
    3134   will be called when the object is reclaimed, unless it is *NULL*.
    3235
    3336
    34 .. cfunction:: PyObject* PyCObject_FromVoidPtrAndDesc(void* cobj, void* desc, void (*destr)(void *, void *))
     37.. c:function:: PyObject* PyCObject_FromVoidPtrAndDesc(void* cobj, void* desc, void (*destr)(void *, void *))
    3538
    36    Create a :ctype:`PyCObject` from the :ctype:`void \*` *cobj*.  The *destr*
     39   Create a :c:type:`PyCObject` from the :c:type:`void \*` *cobj*.  The *destr*
    3740   function will be called when the object is reclaimed. The *desc* argument can
    3841   be used to pass extra callback data for the destructor function.
    3942
    4043
    41 .. cfunction:: void* PyCObject_AsVoidPtr(PyObject* self)
     44.. c:function:: void* PyCObject_AsVoidPtr(PyObject* self)
    4245
    43    Return the object :ctype:`void \*` that the :ctype:`PyCObject` *self* was
     46   Return the object :c:type:`void \*` that the :c:type:`PyCObject` *self* was
    4447   created with.
    4548
    4649
    47 .. cfunction:: void* PyCObject_GetDesc(PyObject* self)
     50.. c:function:: void* PyCObject_GetDesc(PyObject* self)
    4851
    49    Return the description :ctype:`void \*` that the :ctype:`PyCObject` *self* was
     52   Return the description :c:type:`void \*` that the :c:type:`PyCObject` *self* was
    5053   created with.
    5154
    5255
    53 .. cfunction:: int PyCObject_SetVoidPtr(PyObject* self, void* cobj)
     56.. c:function:: int PyCObject_SetVoidPtr(PyObject* self, void* cobj)
    5457
    55    Set the void pointer inside *self* to *cobj*. The :ctype:`PyCObject` must not
     58   Set the void pointer inside *self* to *cobj*. The :c:type:`PyCObject` must not
    5659   have an associated destructor. Return true on success, false on failure.
  • python/vendor/current/Doc/c-api/complex.rst

    r2 r388  
    2222
    2323
    24 .. ctype:: Py_complex
     24.. c:type:: Py_complex
    2525
    2626   The C structure which corresponds to the value portion of a Python complex
     
    3535
    3636
    37 .. cfunction:: Py_complex _Py_c_sum(Py_complex left, Py_complex right)
     37.. c:function:: Py_complex _Py_c_sum(Py_complex left, Py_complex right)
    3838
    39    Return the sum of two complex numbers, using the C :ctype:`Py_complex`
     39   Return the sum of two complex numbers, using the C :c:type:`Py_complex`
    4040   representation.
    4141
    4242
    43 .. cfunction:: Py_complex _Py_c_diff(Py_complex left, Py_complex right)
     43.. c:function:: Py_complex _Py_c_diff(Py_complex left, Py_complex right)
    4444
    4545   Return the difference between two complex numbers, using the C
    46    :ctype:`Py_complex` representation.
     46   :c:type:`Py_complex` representation.
    4747
    4848
    49 .. cfunction:: Py_complex _Py_c_neg(Py_complex complex)
     49.. c:function:: Py_complex _Py_c_neg(Py_complex complex)
    5050
    5151   Return the negation of the complex number *complex*, using the C
    52    :ctype:`Py_complex` representation.
     52   :c:type:`Py_complex` representation.
    5353
    5454
    55 .. cfunction:: Py_complex _Py_c_prod(Py_complex left, Py_complex right)
     55.. c:function:: Py_complex _Py_c_prod(Py_complex left, Py_complex right)
    5656
    57    Return the product of two complex numbers, using the C :ctype:`Py_complex`
     57   Return the product of two complex numbers, using the C :c:type:`Py_complex`
    5858   representation.
    5959
    6060
    61 .. cfunction:: Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor)
     61.. c:function:: Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor)
    6262
    63    Return the quotient of two complex numbers, using the C :ctype:`Py_complex`
     63   Return the quotient of two complex numbers, using the C :c:type:`Py_complex`
    6464   representation.
    6565
     66   If *divisor* is null, this method returns zero and sets
     67   :c:data:`errno` to :c:data:`EDOM`.
    6668
    67 .. cfunction:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp)
    6869
    69    Return the exponentiation of *num* by *exp*, using the C :ctype:`Py_complex`
     70.. c:function:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp)
     71
     72   Return the exponentiation of *num* by *exp*, using the C :c:type:`Py_complex`
    7073   representation.
     74
     75   If *num* is null and *exp* is not a positive real number,
     76   this method returns zero and sets :c:data:`errno` to :c:data:`EDOM`.
    7177
    7278
     
    7581
    7682
    77 .. ctype:: PyComplexObject
     83.. c:type:: PyComplexObject
    7884
    79    This subtype of :ctype:`PyObject` represents a Python complex number object.
     85   This subtype of :c:type:`PyObject` represents a Python complex number object.
    8086
    8187
    82 .. cvar:: PyTypeObject PyComplex_Type
     88.. c:var:: PyTypeObject PyComplex_Type
    8389
    84    This instance of :ctype:`PyTypeObject` represents the Python complex number
     90   This instance of :c:type:`PyTypeObject` represents the Python complex number
    8591   type. It is the same object as ``complex`` and ``types.ComplexType``.
    8692
    8793
    88 .. cfunction:: int PyComplex_Check(PyObject *p)
     94.. c:function:: int PyComplex_Check(PyObject *p)
    8995
    90    Return true if its argument is a :ctype:`PyComplexObject` or a subtype of
    91    :ctype:`PyComplexObject`.
     96   Return true if its argument is a :c:type:`PyComplexObject` or a subtype of
     97   :c:type:`PyComplexObject`.
    9298
    9399   .. versionchanged:: 2.2
     
    95101
    96102
    97 .. cfunction:: int PyComplex_CheckExact(PyObject *p)
     103.. c:function:: int PyComplex_CheckExact(PyObject *p)
    98104
    99    Return true if its argument is a :ctype:`PyComplexObject`, but not a subtype of
    100    :ctype:`PyComplexObject`.
     105   Return true if its argument is a :c:type:`PyComplexObject`, but not a subtype of
     106   :c:type:`PyComplexObject`.
    101107
    102108   .. versionadded:: 2.2
    103109
    104110
    105 .. cfunction:: PyObject* PyComplex_FromCComplex(Py_complex v)
     111.. c:function:: PyObject* PyComplex_FromCComplex(Py_complex v)
    106112
    107    Create a new Python complex number object from a C :ctype:`Py_complex` value.
     113   Create a new Python complex number object from a C :c:type:`Py_complex` value.
    108114
    109115
    110 .. cfunction:: PyObject* PyComplex_FromDoubles(double real, double imag)
     116.. c:function:: PyObject* PyComplex_FromDoubles(double real, double imag)
    111117
    112    Return a new :ctype:`PyComplexObject` object from *real* and *imag*.
     118   Return a new :c:type:`PyComplexObject` object from *real* and *imag*.
    113119
    114120
    115 .. cfunction:: double PyComplex_RealAsDouble(PyObject *op)
     121.. c:function:: double PyComplex_RealAsDouble(PyObject *op)
    116122
    117    Return the real part of *op* as a C :ctype:`double`.
     123   Return the real part of *op* as a C :c:type:`double`.
    118124
    119125
    120 .. cfunction:: double PyComplex_ImagAsDouble(PyObject *op)
     126.. c:function:: double PyComplex_ImagAsDouble(PyObject *op)
    121127
    122    Return the imaginary part of *op* as a C :ctype:`double`.
     128   Return the imaginary part of *op* as a C :c:type:`double`.
    123129
    124130
    125 .. cfunction:: Py_complex PyComplex_AsCComplex(PyObject *op)
     131.. c:function:: Py_complex PyComplex_AsCComplex(PyObject *op)
    126132
    127    Return the :ctype:`Py_complex` value of the complex number *op*.
     133   Return the :c:type:`Py_complex` value of the complex number *op*.
     134   Upon failure, this method returns ``-1.0`` as a real value.
    128135
    129136   .. versionchanged:: 2.6
  • python/vendor/current/Doc/c-api/concrete.rst

    r2 r388  
    1212object from a Python program and you are not sure that it has the right type,
    1313you must perform a type check first; for example, to check that an object is a
    14 dictionary, use :cfunc:`PyDict_Check`.  The chapter is structured like the
     14dictionary, use :c:func:`PyDict_Check`.  The chapter is structured like the
    1515"family tree" of Python object types.
    1616
     
    101101   slice.rst
    102102   weakref.rst
     103   capsule.rst
    103104   cobject.rst
    104105   cell.rst
     
    106107   datetime.rst
    107108   set.rst
     109   code.rst
  • python/vendor/current/Doc/c-api/conversion.rst

    r2 r388  
    99
    1010
    11 .. cfunction:: int PyOS_snprintf(char *str, size_t size,  const char *format, ...)
     11.. c:function:: int PyOS_snprintf(char *str, size_t size,  const char *format, ...)
    1212
    1313   Output not more than *size* bytes to *str* according to the format string
     
    1515
    1616
    17 .. cfunction:: int PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va)
     17.. c:function:: int PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va)
    1818
    1919   Output not more than *size* bytes to *str* according to the format string
     
    2121   :manpage:`vsnprintf(2)`.
    2222
    23 :cfunc:`PyOS_snprintf` and :cfunc:`PyOS_vsnprintf` wrap the Standard C library
    24 functions :cfunc:`snprintf` and :cfunc:`vsnprintf`. Their purpose is to
     23:c:func:`PyOS_snprintf` and :c:func:`PyOS_vsnprintf` wrap the Standard C library
     24functions :c:func:`snprintf` and :c:func:`vsnprintf`. Their purpose is to
    2525guarantee consistent behavior in corner cases, which the Standard C functions do
    2626not.
     
    3131NULL``.
    3232
    33 If the platform doesn't have :cfunc:`vsnprintf` and the buffer size needed to
     33If the platform doesn't have :c:func:`vsnprintf` and the buffer size needed to
    3434avoid truncation exceeds *size* by more than 512 bytes, Python aborts with a
    3535*Py_FatalError*.
     
    5252
    5353
    54 .. cfunction:: double PyOS_ascii_strtod(const char *nptr, char **endptr)
     54.. c:function:: double PyOS_string_to_double(const char *s, char **endptr, PyObject *overflow_exception)
    5555
    56    Convert a string to a :ctype:`double`. This function behaves like the Standard C
    57    function :cfunc:`strtod` does in the C locale. It does this without changing the
     56   Convert a string ``s`` to a :c:type:`double`, raising a Python
     57   exception on failure.  The set of accepted strings corresponds to
     58   the set of strings accepted by Python's :func:`float` constructor,
     59   except that ``s`` must not have leading or trailing whitespace.
     60   The conversion is independent of the current locale.
     61
     62   If ``endptr`` is ``NULL``, convert the whole string.  Raise
     63   ValueError and return ``-1.0`` if the string is not a valid
     64   representation of a floating-point number.
     65
     66   If endptr is not ``NULL``, convert as much of the string as
     67   possible and set ``*endptr`` to point to the first unconverted
     68   character.  If no initial segment of the string is the valid
     69   representation of a floating-point number, set ``*endptr`` to point
     70   to the beginning of the string, raise ValueError, and return
     71   ``-1.0``.
     72
     73   If ``s`` represents a value that is too large to store in a float
     74   (for example, ``"1e500"`` is such a string on many platforms) then
     75   if ``overflow_exception`` is ``NULL`` return ``Py_HUGE_VAL`` (with
     76   an appropriate sign) and don't set any exception.  Otherwise,
     77   ``overflow_exception`` must point to a Python exception object;
     78   raise that exception and return ``-1.0``.  In both cases, set
     79   ``*endptr`` to point to the first character after the converted value.
     80
     81   If any other error occurs during the conversion (for example an
     82   out-of-memory error), set the appropriate Python exception and
     83   return ``-1.0``.
     84
     85   .. versionadded:: 2.7
     86
     87
     88.. c:function:: double PyOS_ascii_strtod(const char *nptr, char **endptr)
     89
     90   Convert a string to a :c:type:`double`. This function behaves like the Standard C
     91   function :c:func:`strtod` does in the C locale. It does this without changing the
    5892   current locale, since that would not be thread-safe.
    5993
    60    :cfunc:`PyOS_ascii_strtod` should typically be used for reading configuration
     94   :c:func:`PyOS_ascii_strtod` should typically be used for reading configuration
    6195   files or other non-user input that should be locale independent.
     96
     97   See the Unix man page :manpage:`strtod(2)` for details.
    6298
    6399   .. versionadded:: 2.4
    64100
    65    See the Unix man page :manpage:`strtod(2)` for details.
     101   .. deprecated:: 2.7
     102      Use :c:func:`PyOS_string_to_double` instead.
    66103
    67104
    68 .. cfunction:: char * PyOS_ascii_formatd(char *buffer, size_t buf_len, const char *format, double d)
    69105
    70    Convert a :ctype:`double` to a string using the ``'.'`` as the decimal
    71    separator. *format* is a :cfunc:`printf`\ -style format string specifying the
     106.. c:function:: char* PyOS_ascii_formatd(char *buffer, size_t buf_len, const char *format, double d)
     107
     108   Convert a :c:type:`double` to a string using the ``'.'`` as the decimal
     109   separator. *format* is a :c:func:`printf`\ -style format string specifying the
    72110   number format. Allowed conversion characters are ``'e'``, ``'E'``, ``'f'``,
    73111   ``'F'``, ``'g'`` and ``'G'``.
     
    77115
    78116   .. versionadded:: 2.4
     117   .. deprecated:: 2.7
     118      This function is removed in Python 2.7 and 3.1.  Use :func:`PyOS_double_to_string`
     119      instead.
    79120
    80121
    81 .. cfunction:: double PyOS_ascii_atof(const char *nptr)
     122.. c:function:: char* PyOS_double_to_string(double val, char format_code, int precision, int flags, int *ptype)
    82123
    83    Convert a string to a :ctype:`double` in a locale-independent way.
     124   Convert a :c:type:`double` *val* to a string using supplied
     125   *format_code*, *precision*, and *flags*.
     126
     127   *format_code* must be one of ``'e'``, ``'E'``, ``'f'``, ``'F'``,
     128   ``'g'``, ``'G'`` or ``'r'``.  For ``'r'``, the supplied *precision*
     129   must be 0 and is ignored.  The ``'r'`` format code specifies the
     130   standard :func:`repr` format.
     131
     132   *flags* can be zero or more of the values *Py_DTSF_SIGN*,
     133   *Py_DTSF_ADD_DOT_0*, or *Py_DTSF_ALT*, or-ed together:
     134
     135   * *Py_DTSF_SIGN* means to always precede the returned string with a sign
     136     character, even if *val* is non-negative.
     137
     138   * *Py_DTSF_ADD_DOT_0* means to ensure that the returned string will not look
     139     like an integer.
     140
     141   * *Py_DTSF_ALT* means to apply "alternate" formatting rules.  See the
     142     documentation for the :c:func:`PyOS_snprintf` ``'#'`` specifier for
     143     details.
     144
     145   If *ptype* is non-NULL, then the value it points to will be set to one of
     146   *Py_DTST_FINITE*, *Py_DTST_INFINITE*, or *Py_DTST_NAN*, signifying that
     147   *val* is a finite number, an infinite number, or not a number, respectively.
     148
     149   The return value is a pointer to *buffer* with the converted string or
     150   *NULL* if the conversion failed. The caller is responsible for freeing the
     151   returned string by calling :c:func:`PyMem_Free`.
     152
     153   .. versionadded:: 2.7
     154
     155
     156.. c:function:: double PyOS_ascii_atof(const char *nptr)
     157
     158   Convert a string to a :c:type:`double` in a locale-independent way.
     159
     160   See the Unix man page :manpage:`atof(2)` for details.
    84161
    85162   .. versionadded:: 2.4
    86163
    87    See the Unix man page :manpage:`atof(2)` for details.
     164   .. deprecated:: 3.1
     165      Use :c:func:`PyOS_string_to_double` instead.
    88166
    89167
    90 .. cfunction:: char * PyOS_stricmp(char *s1, char *s2)
     168.. c:function:: char* PyOS_stricmp(char *s1, char *s2)
    91169
    92170   Case insensitive comparison of strings. The function works almost
    93    identically to :cfunc:`strcmp` except that it ignores the case.
     171   identically to :c:func:`strcmp` except that it ignores the case.
    94172
    95173   .. versionadded:: 2.6
    96174
    97175
    98 .. cfunction:: char * PyOS_strnicmp(char *s1, char *s2, Py_ssize_t  size)
     176.. c:function:: char* PyOS_strnicmp(char *s1, char *s2, Py_ssize_t  size)
    99177
    100178   Case insensitive comparison of strings. The function works almost
    101    identically to :cfunc:`strncmp` except that it ignores the case.
     179   identically to :c:func:`strncmp` except that it ignores the case.
    102180
    103181   .. versionadded:: 2.6
  • python/vendor/current/Doc/c-api/datetime.rst

    r2 r388  
    99Before using any of these functions, the header file :file:`datetime.h` must be
    1010included in your source (note that this is not included by :file:`Python.h`),
    11 and the macro :cfunc:`PyDateTime_IMPORT` must be invoked.  The macro puts a
    12 pointer to a C structure into a static variable,  ``PyDateTimeAPI``, that is
    13 used by the following macros.
     11and the macro :c:macro:`PyDateTime_IMPORT` must be invoked, usually as part of
     12the module initialisation function.  The macro puts a pointer to a C structure
     13into a static variable, :c:data:`PyDateTimeAPI`, that is used by the following
     14macros.
    1415
    1516Type-check macros:
    1617
    1718
    18 .. cfunction:: int PyDate_Check(PyObject *ob)
    19 
    20    Return true if *ob* is of type :cdata:`PyDateTime_DateType` or a subtype of
    21    :cdata:`PyDateTime_DateType`.  *ob* must not be *NULL*.
    22 
    23    .. versionadded:: 2.4
    24 
    25 
    26 .. cfunction:: int PyDate_CheckExact(PyObject *ob)
    27 
    28    Return true if *ob* is of type :cdata:`PyDateTime_DateType`. *ob* must not be
    29    *NULL*.
    30 
    31    .. versionadded:: 2.4
    32 
    33 
    34 .. cfunction:: int PyDateTime_Check(PyObject *ob)
    35 
    36    Return true if *ob* is of type :cdata:`PyDateTime_DateTimeType` or a subtype of
    37    :cdata:`PyDateTime_DateTimeType`.  *ob* must not be *NULL*.
    38 
    39    .. versionadded:: 2.4
    40 
    41 
    42 .. cfunction:: int PyDateTime_CheckExact(PyObject *ob)
    43 
    44    Return true if *ob* is of type :cdata:`PyDateTime_DateTimeType`. *ob* must not
     19.. c:function:: int PyDate_Check(PyObject *ob)
     20
     21   Return true if *ob* is of type :c:data:`PyDateTime_DateType` or a subtype of
     22   :c:data:`PyDateTime_DateType`.  *ob* must not be *NULL*.
     23
     24   .. versionadded:: 2.4
     25
     26
     27.. c:function:: int PyDate_CheckExact(PyObject *ob)
     28
     29   Return true if *ob* is of type :c:data:`PyDateTime_DateType`. *ob* must not be
     30   *NULL*.
     31
     32   .. versionadded:: 2.4
     33
     34
     35.. c:function:: int PyDateTime_Check(PyObject *ob)
     36
     37   Return true if *ob* is of type :c:data:`PyDateTime_DateTimeType` or a subtype of
     38   :c:data:`PyDateTime_DateTimeType`.  *ob* must not be *NULL*.
     39
     40   .. versionadded:: 2.4
     41
     42
     43.. c:function:: int PyDateTime_CheckExact(PyObject *ob)
     44
     45   Return true if *ob* is of type :c:data:`PyDateTime_DateTimeType`. *ob* must not
    4546   be *NULL*.
    4647
     
    4849
    4950
    50 .. cfunction:: int PyTime_Check(PyObject *ob)
    51 
    52    Return true if *ob* is of type :cdata:`PyDateTime_TimeType` or a subtype of
    53    :cdata:`PyDateTime_TimeType`.  *ob* must not be *NULL*.
    54 
    55    .. versionadded:: 2.4
    56 
    57 
    58 .. cfunction:: int PyTime_CheckExact(PyObject *ob)
    59 
    60    Return true if *ob* is of type :cdata:`PyDateTime_TimeType`. *ob* must not be
    61    *NULL*.
    62 
    63    .. versionadded:: 2.4
    64 
    65 
    66 .. cfunction:: int PyDelta_Check(PyObject *ob)
    67 
    68    Return true if *ob* is of type :cdata:`PyDateTime_DeltaType` or a subtype of
    69    :cdata:`PyDateTime_DeltaType`.  *ob* must not be *NULL*.
    70 
    71    .. versionadded:: 2.4
    72 
    73 
    74 .. cfunction:: int PyDelta_CheckExact(PyObject *ob)
    75 
    76    Return true if *ob* is of type :cdata:`PyDateTime_DeltaType`. *ob* must not be
    77    *NULL*.
    78 
    79    .. versionadded:: 2.4
    80 
    81 
    82 .. cfunction:: int PyTZInfo_Check(PyObject *ob)
    83 
    84    Return true if *ob* is of type :cdata:`PyDateTime_TZInfoType` or a subtype of
    85    :cdata:`PyDateTime_TZInfoType`.  *ob* must not be *NULL*.
    86 
    87    .. versionadded:: 2.4
    88 
    89 
    90 .. cfunction:: int PyTZInfo_CheckExact(PyObject *ob)
    91 
    92    Return true if *ob* is of type :cdata:`PyDateTime_TZInfoType`. *ob* must not be
     51.. c:function:: int PyTime_Check(PyObject *ob)
     52
     53   Return true if *ob* is of type :c:data:`PyDateTime_TimeType` or a subtype of
     54   :c:data:`PyDateTime_TimeType`.  *ob* must not be *NULL*.
     55
     56   .. versionadded:: 2.4
     57
     58
     59.. c:function:: int PyTime_CheckExact(PyObject *ob)
     60
     61   Return true if *ob* is of type :c:data:`PyDateTime_TimeType`. *ob* must not be
     62   *NULL*.
     63
     64   .. versionadded:: 2.4
     65
     66
     67.. c:function:: int PyDelta_Check(PyObject *ob)
     68
     69   Return true if *ob* is of type :c:data:`PyDateTime_DeltaType` or a subtype of
     70   :c:data:`PyDateTime_DeltaType`.  *ob* must not be *NULL*.
     71
     72   .. versionadded:: 2.4
     73
     74
     75.. c:function:: int PyDelta_CheckExact(PyObject *ob)
     76
     77   Return true if *ob* is of type :c:data:`PyDateTime_DeltaType`. *ob* must not be
     78   *NULL*.
     79
     80   .. versionadded:: 2.4
     81
     82
     83.. c:function:: int PyTZInfo_Check(PyObject *ob)
     84
     85   Return true if *ob* is of type :c:data:`PyDateTime_TZInfoType` or a subtype of
     86   :c:data:`PyDateTime_TZInfoType`.  *ob* must not be *NULL*.
     87
     88   .. versionadded:: 2.4
     89
     90
     91.. c:function:: int PyTZInfo_CheckExact(PyObject *ob)
     92
     93   Return true if *ob* is of type :c:data:`PyDateTime_TZInfoType`. *ob* must not be
    9394   *NULL*.
    9495
     
    9899
    99100
    100 .. cfunction:: PyObject* PyDate_FromDate(int year, int month, int day)
     101.. c:function:: PyObject* PyDate_FromDate(int year, int month, int day)
    101102
    102103   Return a ``datetime.date`` object with the specified year, month and day.
     
    105106
    106107
    107 .. cfunction:: PyObject* PyDateTime_FromDateAndTime(int year, int month, int day, int hour, int minute, int second, int usecond)
     108.. c:function:: PyObject* PyDateTime_FromDateAndTime(int year, int month, int day, int hour, int minute, int second, int usecond)
    108109
    109110   Return a ``datetime.datetime`` object with the specified year, month, day, hour,
     
    113114
    114115
    115 .. cfunction:: PyObject* PyTime_FromTime(int hour, int minute, int second, int usecond)
     116.. c:function:: PyObject* PyTime_FromTime(int hour, int minute, int second, int usecond)
    116117
    117118   Return a ``datetime.time`` object with the specified hour, minute, second and
     
    121122
    122123
    123 .. cfunction:: PyObject* PyDelta_FromDSU(int days, int seconds, int useconds)
     124.. c:function:: PyObject* PyDelta_FromDSU(int days, int seconds, int useconds)
    124125
    125126   Return a ``datetime.timedelta`` object representing the given number of days,
     
    131132
    132133Macros to extract fields from date objects.  The argument must be an instance of
    133 :cdata:`PyDateTime_Date`, including subclasses (such as
    134 :cdata:`PyDateTime_DateTime`).  The argument must not be *NULL*, and the type is
     134:c:data:`PyDateTime_Date`, including subclasses (such as
     135:c:data:`PyDateTime_DateTime`).  The argument must not be *NULL*, and the type is
    135136not checked:
    136137
    137138
    138 .. cfunction:: int PyDateTime_GET_YEAR(PyDateTime_Date *o)
     139.. c:function:: int PyDateTime_GET_YEAR(PyDateTime_Date *o)
    139140
    140141   Return the year, as a positive int.
     
    143144
    144145
    145 .. cfunction:: int PyDateTime_GET_MONTH(PyDateTime_Date *o)
     146.. c:function:: int PyDateTime_GET_MONTH(PyDateTime_Date *o)
    146147
    147148   Return the month, as an int from 1 through 12.
     
    150151
    151152
    152 .. cfunction:: int PyDateTime_GET_DAY(PyDateTime_Date *o)
     153.. c:function:: int PyDateTime_GET_DAY(PyDateTime_Date *o)
    153154
    154155   Return the day, as an int from 1 through 31.
     
    157158
    158159Macros to extract fields from datetime objects.  The argument must be an
    159 instance of :cdata:`PyDateTime_DateTime`, including subclasses. The argument
     160instance of :c:data:`PyDateTime_DateTime`, including subclasses. The argument
    160161must not be *NULL*, and the type is not checked:
    161162
    162163
    163 .. cfunction:: int PyDateTime_DATE_GET_HOUR(PyDateTime_DateTime *o)
     164.. c:function:: int PyDateTime_DATE_GET_HOUR(PyDateTime_DateTime *o)
    164165
    165166   Return the hour, as an int from 0 through 23.
     
    168169
    169170
    170 .. cfunction:: int PyDateTime_DATE_GET_MINUTE(PyDateTime_DateTime *o)
     171.. c:function:: int PyDateTime_DATE_GET_MINUTE(PyDateTime_DateTime *o)
    171172
    172173   Return the minute, as an int from 0 through 59.
     
    175176
    176177
    177 .. cfunction:: int PyDateTime_DATE_GET_SECOND(PyDateTime_DateTime *o)
     178.. c:function:: int PyDateTime_DATE_GET_SECOND(PyDateTime_DateTime *o)
    178179
    179180   Return the second, as an int from 0 through 59.
     
    182183
    183184
    184 .. cfunction:: int PyDateTime_DATE_GET_MICROSECOND(PyDateTime_DateTime *o)
     185.. c:function:: int PyDateTime_DATE_GET_MICROSECOND(PyDateTime_DateTime *o)
    185186
    186187   Return the microsecond, as an int from 0 through 999999.
     
    189190
    190191Macros to extract fields from time objects.  The argument must be an instance of
    191 :cdata:`PyDateTime_Time`, including subclasses. The argument must not be *NULL*,
     192:c:data:`PyDateTime_Time`, including subclasses. The argument must not be *NULL*,
    192193and the type is not checked:
    193194
    194195
    195 .. cfunction:: int PyDateTime_TIME_GET_HOUR(PyDateTime_Time *o)
     196.. c:function:: int PyDateTime_TIME_GET_HOUR(PyDateTime_Time *o)
    196197
    197198   Return the hour, as an int from 0 through 23.
     
    200201
    201202
    202 .. cfunction:: int PyDateTime_TIME_GET_MINUTE(PyDateTime_Time *o)
     203.. c:function:: int PyDateTime_TIME_GET_MINUTE(PyDateTime_Time *o)
    203204
    204205   Return the minute, as an int from 0 through 59.
     
    207208
    208209
    209 .. cfunction:: int PyDateTime_TIME_GET_SECOND(PyDateTime_Time *o)
     210.. c:function:: int PyDateTime_TIME_GET_SECOND(PyDateTime_Time *o)
    210211
    211212   Return the second, as an int from 0 through 59.
     
    214215
    215216
    216 .. cfunction:: int PyDateTime_TIME_GET_MICROSECOND(PyDateTime_Time *o)
     217.. c:function:: int PyDateTime_TIME_GET_MICROSECOND(PyDateTime_Time *o)
    217218
    218219   Return the microsecond, as an int from 0 through 999999.
     
    223224
    224225
    225 .. cfunction:: PyObject* PyDateTime_FromTimestamp(PyObject *args)
     226.. c:function:: PyObject* PyDateTime_FromTimestamp(PyObject *args)
    226227
    227228   Create and return a new ``datetime.datetime`` object given an argument tuple
     
    231232
    232233
    233 .. cfunction:: PyObject* PyDate_FromTimestamp(PyObject *args)
     234.. c:function:: PyObject* PyDate_FromTimestamp(PyObject *args)
    234235
    235236   Create and return a new ``datetime.date`` object given an argument tuple
  • python/vendor/current/Doc/c-api/descriptor.rst

    r2 r388  
    1010
    1111
    12 .. cvar:: PyTypeObject PyProperty_Type
     12.. c:var:: PyTypeObject PyProperty_Type
    1313
    1414   The type object for the built-in descriptor types.
     
    1717
    1818
    19 .. cfunction:: PyObject* PyDescr_NewGetSet(PyTypeObject *type, struct PyGetSetDef *getset)
     19.. c:function:: PyObject* PyDescr_NewGetSet(PyTypeObject *type, struct PyGetSetDef *getset)
    2020
    2121   .. versionadded:: 2.2
    2222
    2323
    24 .. cfunction:: PyObject* PyDescr_NewMember(PyTypeObject *type, struct PyMemberDef *meth)
     24.. c:function:: PyObject* PyDescr_NewMember(PyTypeObject *type, struct PyMemberDef *meth)
    2525
    2626   .. versionadded:: 2.2
    2727
    2828
    29 .. cfunction:: PyObject* PyDescr_NewMethod(PyTypeObject *type, struct PyMethodDef *meth)
     29.. c:function:: PyObject* PyDescr_NewMethod(PyTypeObject *type, struct PyMethodDef *meth)
    3030
    3131   .. versionadded:: 2.2
    3232
    3333
    34 .. cfunction:: PyObject* PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *wrapper, void *wrapped)
     34.. c:function:: PyObject* PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *wrapper, void *wrapped)
    3535
    3636   .. versionadded:: 2.2
    3737
    3838
    39 .. cfunction:: PyObject* PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method)
     39.. c:function:: PyObject* PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method)
    4040
    4141   .. versionadded:: 2.3
    4242
    4343
    44 .. cfunction:: int PyDescr_IsData(PyObject *descr)
     44.. c:function:: int PyDescr_IsData(PyObject *descr)
    4545
    4646   Return true if the descriptor objects *descr* describes a data attribute, or
     
    5151
    5252
    53 .. cfunction:: PyObject* PyWrapper_New(PyObject *, PyObject *)
     53.. c:function:: PyObject* PyWrapper_New(PyObject *, PyObject *)
    5454
    5555   .. versionadded:: 2.2
  • python/vendor/current/Doc/c-api/dict.rst

    r2 r388  
    99
    1010
    11 .. ctype:: PyDictObject
    12 
    13    This subtype of :ctype:`PyObject` represents a Python dictionary object.
    14 
    15 
    16 .. cvar:: PyTypeObject PyDict_Type
     11.. c:type:: PyDictObject
     12
     13   This subtype of :c:type:`PyObject` represents a Python dictionary object.
     14
     15
     16.. c:var:: PyTypeObject PyDict_Type
    1717
    1818   .. index::
     
    2020      single: DictionaryType (in module types)
    2121
    22    This instance of :ctype:`PyTypeObject` represents the Python dictionary
     22   This instance of :c:type:`PyTypeObject` represents the Python dictionary
    2323   type.  This is exposed to Python programs as ``dict`` and
    2424   ``types.DictType``.
    2525
    2626
    27 .. cfunction:: int PyDict_Check(PyObject *p)
     27.. c:function:: int PyDict_Check(PyObject *p)
    2828
    2929   Return true if *p* is a dict object or an instance of a subtype of the dict
     
    3434
    3535
    36 .. cfunction:: int PyDict_CheckExact(PyObject *p)
     36.. c:function:: int PyDict_CheckExact(PyObject *p)
    3737
    3838   Return true if *p* is a dict object, but not an instance of a subtype of
     
    4242
    4343
    44 .. cfunction:: PyObject* PyDict_New()
     44.. c:function:: PyObject* PyDict_New()
    4545
    4646   Return a new empty dictionary, or *NULL* on failure.
    4747
    4848
    49 .. cfunction:: PyObject* PyDictProxy_New(PyObject *dict)
     49.. c:function:: PyObject* PyDictProxy_New(PyObject *dict)
    5050
    5151   Return a proxy object for a mapping which enforces read-only behavior.
     
    5656
    5757
    58 .. cfunction:: void PyDict_Clear(PyObject *p)
     58.. c:function:: void PyDict_Clear(PyObject *p)
    5959
    6060   Empty an existing dictionary of all key-value pairs.
    6161
    6262
    63 .. cfunction:: int PyDict_Contains(PyObject *p, PyObject *key)
     63.. c:function:: int PyDict_Contains(PyObject *p, PyObject *key)
    6464
    6565   Determine if dictionary *p* contains *key*.  If an item in *p* is matches
     
    7070
    7171
    72 .. cfunction:: PyObject* PyDict_Copy(PyObject *p)
     72.. c:function:: PyObject* PyDict_Copy(PyObject *p)
    7373
    7474   Return a new dictionary that contains the same key-value pairs as *p*.
     
    7777
    7878
    79 .. cfunction:: int PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val)
     79.. c:function:: int PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val)
    8080
    8181   Insert *value* into the dictionary *p* with a key of *key*.  *key* must be
     
    8484
    8585
    86 .. cfunction:: int PyDict_SetItemString(PyObject *p, const char *key, PyObject *val)
     86.. c:function:: int PyDict_SetItemString(PyObject *p, const char *key, PyObject *val)
    8787
    8888   .. index:: single: PyString_FromString()
    8989
    9090   Insert *value* into the dictionary *p* using *key* as a key. *key* should
    91    be a :ctype:`char\*`.  The key object is created using
     91   be a :c:type:`char\*`.  The key object is created using
    9292   ``PyString_FromString(key)``.  Return ``0`` on success or ``-1`` on
    9393   failure.
    9494
    9595
    96 .. cfunction:: int PyDict_DelItem(PyObject *p, PyObject *key)
     96.. c:function:: int PyDict_DelItem(PyObject *p, PyObject *key)
    9797
    9898   Remove the entry in dictionary *p* with key *key*. *key* must be hashable;
     
    101101
    102102
    103 .. cfunction:: int PyDict_DelItemString(PyObject *p, char *key)
     103.. c:function:: int PyDict_DelItemString(PyObject *p, char *key)
    104104
    105105   Remove the entry in dictionary *p* which has a key specified by the string
     
    107107
    108108
    109 .. cfunction:: PyObject* PyDict_GetItem(PyObject *p, PyObject *key)
     109.. c:function:: PyObject* PyDict_GetItem(PyObject *p, PyObject *key)
    110110
    111111   Return the object from dictionary *p* which has a key *key*.  Return *NULL*
     
    113113
    114114
    115 .. cfunction:: PyObject* PyDict_GetItemString(PyObject *p, const char *key)
    116 
    117    This is the same as :cfunc:`PyDict_GetItem`, but *key* is specified as a
    118    :ctype:`char\*`, rather than a :ctype:`PyObject\*`.
    119 
    120 
    121 .. cfunction:: PyObject* PyDict_Items(PyObject *p)
    122 
    123    Return a :ctype:`PyListObject` containing all the items from the
     115.. c:function:: PyObject* PyDict_GetItemString(PyObject *p, const char *key)
     116
     117   This is the same as :c:func:`PyDict_GetItem`, but *key* is specified as a
     118   :c:type:`char\*`, rather than a :c:type:`PyObject\*`.
     119
     120
     121.. c:function:: PyObject* PyDict_Items(PyObject *p)
     122
     123   Return a :c:type:`PyListObject` containing all the items from the
    124124   dictionary, as in the dictionary method :meth:`dict.items`.
    125125
    126126
    127 .. cfunction:: PyObject* PyDict_Keys(PyObject *p)
    128 
    129    Return a :ctype:`PyListObject` containing all the keys from the dictionary,
     127.. c:function:: PyObject* PyDict_Keys(PyObject *p)
     128
     129   Return a :c:type:`PyListObject` containing all the keys from the dictionary,
    130130   as in the dictionary method :meth:`dict.keys`.
    131131
    132132
    133 .. cfunction:: PyObject* PyDict_Values(PyObject *p)
    134 
    135    Return a :ctype:`PyListObject` containing all the values from the
     133.. c:function:: PyObject* PyDict_Values(PyObject *p)
     134
     135   Return a :c:type:`PyListObject` containing all the values from the
    136136   dictionary *p*, as in the dictionary method :meth:`dict.values`.
    137137
    138138
    139 .. cfunction:: Py_ssize_t PyDict_Size(PyObject *p)
     139.. c:function:: Py_ssize_t PyDict_Size(PyObject *p)
    140140
    141141   .. index:: builtin: len
     
    145145
    146146   .. versionchanged:: 2.5
    147       This function returned an :ctype:`int` type.  This might require changes
     147      This function returned an :c:type:`int` type.  This might require changes
    148148      in your code for properly supporting 64-bit systems.
    149149
    150150
    151 .. cfunction:: int PyDict_Next(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue)
     151.. c:function:: int PyDict_Next(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue)
    152152
    153153   Iterate over all key-value pairs in the dictionary *p*.  The
    154    :ctype:`Py_ssize_t` referred to by *ppos* must be initialized to ``0``
     154   :c:type:`Py_ssize_t` referred to by *ppos* must be initialized to ``0``
    155155   prior to the first call to this function to start the iteration; the
    156156   function returns true for each pair in the dictionary, and false once all
    157157   pairs have been reported.  The parameters *pkey* and *pvalue* should either
    158    point to :ctype:`PyObject\*` variables that will be filled in with each key
     158   point to :c:type:`PyObject\*` variables that will be filled in with each key
    159159   and value, respectively, or may be *NULL*.  Any references returned through
    160160   them are borrowed.  *ppos* should not be altered during iteration. Its
     
    193193
    194194   .. versionchanged:: 2.5
    195       This function used an :ctype:`int *` type for *ppos*. This might require
     195      This function used an :c:type:`int *` type for *ppos*. This might require
    196196      changes in your code for properly supporting 64-bit systems.
    197197
    198198
    199 .. cfunction:: int PyDict_Merge(PyObject *a, PyObject *b, int override)
     199.. c:function:: int PyDict_Merge(PyObject *a, PyObject *b, int override)
    200200
    201201   Iterate over mapping object *b* adding key-value pairs to dictionary *a*.
    202    *b* may be a dictionary, or any object supporting :func:`PyMapping_Keys`
    203    and :func:`PyObject_GetItem`. If *override* is true, existing pairs in *a*
     202   *b* may be a dictionary, or any object supporting :c:func:`PyMapping_Keys`
     203   and :c:func:`PyObject_GetItem`. If *override* is true, existing pairs in *a*
    204204   will be replaced if a matching key is found in *b*, otherwise pairs will
    205205   only be added if there is not a matching key in *a*. Return ``0`` on
     
    209209
    210210
    211 .. cfunction:: int PyDict_Update(PyObject *a, PyObject *b)
     211.. c:function:: int PyDict_Update(PyObject *a, PyObject *b)
    212212
    213213   This is the same as ``PyDict_Merge(a, b, 1)`` in C, or ``a.update(b)`` in
     
    217217
    218218
    219 .. cfunction:: int PyDict_MergeFromSeq2(PyObject *a, PyObject *seq2, int override)
     219.. c:function:: int PyDict_MergeFromSeq2(PyObject *a, PyObject *seq2, int override)
    220220
    221221   Update or merge into dictionary *a*, from the key-value pairs in *seq2*.
  • python/vendor/current/Doc/c-api/exceptions.rst

    r2 r388  
    1010The functions described in this chapter will let you handle and raise Python
    1111exceptions.  It is important to understand some of the basics of Python
    12 exception handling.  It works somewhat like the Unix :cdata:`errno` variable:
     12exception handling.  It works somewhat like the Unix :c:data:`errno` variable:
    1313there is a global indicator (per thread) of the last error that occurred.  Most
    1414functions don't clear this on success, but will set it to indicate the cause of
    1515the error on failure.  Most functions also return an error indicator, usually
    1616*NULL* if they are supposed to return a pointer, or ``-1`` if they return an
    17 integer (exception: the :cfunc:`PyArg_\*` functions return ``1`` for success and
     17integer (exception: the :c:func:`PyArg_\*` functions return ``1`` for success and
    1818``0`` for failure).
    1919
     
    4242
    4343
    44 .. cfunction:: void PyErr_PrintEx(int set_sys_last_vars)
     44.. c:function:: void PyErr_PrintEx(int set_sys_last_vars)
    4545
    4646   Print a standard traceback to ``sys.stderr`` and clear the error indicator.
     
    5353
    5454
    55 .. cfunction:: void PyErr_Print()
     55.. c:function:: void PyErr_Print()
    5656
    5757   Alias for ``PyErr_PrintEx(1)``.
    5858
    5959
    60 .. cfunction:: PyObject* PyErr_Occurred()
     60.. c:function:: PyObject* PyErr_Occurred()
    6161
    6262   Test whether the error indicator is set.  If set, return the exception *type*
    63    (the first argument to the last call to one of the :cfunc:`PyErr_Set\*`
    64    functions or to :cfunc:`PyErr_Restore`).  If not set, return *NULL*.  You do not
    65    own a reference to the return value, so you do not need to :cfunc:`Py_DECREF`
     63   (the first argument to the last call to one of the :c:func:`PyErr_Set\*`
     64   functions or to :c:func:`PyErr_Restore`).  If not set, return *NULL*.  You do not
     65   own a reference to the return value, so you do not need to :c:func:`Py_DECREF`
    6666   it.
    6767
     
    6969
    7070      Do not compare the return value to a specific exception; use
    71       :cfunc:`PyErr_ExceptionMatches` instead, shown below.  (The comparison could
     71      :c:func:`PyErr_ExceptionMatches` instead, shown below.  (The comparison could
    7272      easily fail since the exception may be an instance instead of a class, in the
    7373      case of a class exception, or it may the a subclass of the expected exception.)
    7474
    7575
    76 .. cfunction:: int PyErr_ExceptionMatches(PyObject *exc)
     76.. c:function:: int PyErr_ExceptionMatches(PyObject *exc)
    7777
    7878   Equivalent to ``PyErr_GivenExceptionMatches(PyErr_Occurred(), exc)``.  This
     
    8181
    8282
    83 .. cfunction:: int PyErr_GivenExceptionMatches(PyObject *given, PyObject *exc)
     83.. c:function:: int PyErr_GivenExceptionMatches(PyObject *given, PyObject *exc)
    8484
    8585   Return true if the *given* exception matches the exception in *exc*.  If
     
    8989
    9090
    91 .. cfunction:: void PyErr_NormalizeException(PyObject**exc, PyObject**val, PyObject**tb)
    92 
    93    Under certain circumstances, the values returned by :cfunc:`PyErr_Fetch` below
     91.. c:function:: void PyErr_NormalizeException(PyObject**exc, PyObject**val, PyObject**tb)
     92
     93   Under certain circumstances, the values returned by :c:func:`PyErr_Fetch` below
    9494   can be "unnormalized", meaning that ``*exc`` is a class object but ``*val`` is
    9595   not an instance of the  same class.  This function can be used to instantiate
     
    9898
    9999
    100 .. cfunction:: void PyErr_Clear()
     100.. c:function:: void PyErr_Clear()
    101101
    102102   Clear the error indicator.  If the error indicator is not set, there is no
     
    104104
    105105
    106 .. cfunction:: void PyErr_Fetch(PyObject **ptype, PyObject **pvalue, PyObject **ptraceback)
     106.. c:function:: void PyErr_Fetch(PyObject **ptype, PyObject **pvalue, PyObject **ptraceback)
    107107
    108108   Retrieve the error indicator into three variables whose addresses are passed.
     
    117117
    118118
    119 .. cfunction:: void PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback)
     119.. c:function:: void PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback)
    120120
    121121   Set  the error indicator from the three objects.  If the error indicator is
     
    132132
    133133      This function is normally only used by code that needs to save and restore the
    134       error indicator temporarily; use :cfunc:`PyErr_Fetch` to save the current
     134      error indicator temporarily; use :c:func:`PyErr_Fetch` to save the current
    135135      exception state.
    136136
    137137
    138 .. cfunction:: void PyErr_SetString(PyObject *type, const char *message)
     138.. c:function:: void PyErr_SetString(PyObject *type, const char *message)
    139139
    140140   This is the most common way to set the error indicator.  The first argument
    141141   specifies the exception type; it is normally one of the standard exceptions,
    142    e.g. :cdata:`PyExc_RuntimeError`.  You need not increment its reference count.
     142   e.g. :c:data:`PyExc_RuntimeError`.  You need not increment its reference count.
    143143   The second argument is an error message; it is converted to a string object.
    144144
    145145
    146 .. cfunction:: void PyErr_SetObject(PyObject *type, PyObject *value)
    147 
    148    This function is similar to :cfunc:`PyErr_SetString` but lets you specify an
     146.. c:function:: void PyErr_SetObject(PyObject *type, PyObject *value)
     147
     148   This function is similar to :c:func:`PyErr_SetString` but lets you specify an
    149149   arbitrary Python object for the "value" of the exception.
    150150
    151151
    152 .. cfunction:: PyObject* PyErr_Format(PyObject *exception, const char *format, ...)
    153 
    154    This function sets the error indicator and returns *NULL*. *exception* should be
    155    a Python exception (class, not an instance).  *format* should be a string,
    156    containing format codes, similar to :cfunc:`printf`. The ``width.precision``
    157    before a format code is parsed, but the width part is ignored.
    158 
    159    .. % This should be exactly the same as the table in PyString_FromFormat.
    160    .. % One should just refer to the other.
    161    .. % The descriptions for %zd and %zu are wrong, but the truth is complicated
    162    .. % because not all compilers support the %z width modifier -- we fake it
    163    .. % when necessary via interpolating PY_FORMAT_SIZE_T.
    164    .. % %u, %lu, %zu should have "new in Python 2.5" blurbs.
    165 
    166    +-------------------+---------------+--------------------------------+
    167    | Format Characters | Type          | Comment                        |
    168    +===================+===============+================================+
    169    | :attr:`%%`        | *n/a*         | The literal % character.       |
    170    +-------------------+---------------+--------------------------------+
    171    | :attr:`%c`        | int           | A single character,            |
    172    |                   |               | represented as an C int.       |
    173    +-------------------+---------------+--------------------------------+
    174    | :attr:`%d`        | int           | Exactly equivalent to          |
    175    |                   |               | ``printf("%d")``.              |
    176    +-------------------+---------------+--------------------------------+
    177    | :attr:`%u`        | unsigned int  | Exactly equivalent to          |
    178    |                   |               | ``printf("%u")``.              |
    179    +-------------------+---------------+--------------------------------+
    180    | :attr:`%ld`       | long          | Exactly equivalent to          |
    181    |                   |               | ``printf("%ld")``.             |
    182    +-------------------+---------------+--------------------------------+
    183    | :attr:`%lu`       | unsigned long | Exactly equivalent to          |
    184    |                   |               | ``printf("%lu")``.             |
    185    +-------------------+---------------+--------------------------------+
    186    | :attr:`%zd`       | Py_ssize_t    | Exactly equivalent to          |
    187    |                   |               | ``printf("%zd")``.             |
    188    +-------------------+---------------+--------------------------------+
    189    | :attr:`%zu`       | size_t        | Exactly equivalent to          |
    190    |                   |               | ``printf("%zu")``.             |
    191    +-------------------+---------------+--------------------------------+
    192    | :attr:`%i`        | int           | Exactly equivalent to          |
    193    |                   |               | ``printf("%i")``.              |
    194    +-------------------+---------------+--------------------------------+
    195    | :attr:`%x`        | int           | Exactly equivalent to          |
    196    |                   |               | ``printf("%x")``.              |
    197    +-------------------+---------------+--------------------------------+
    198    | :attr:`%s`        | char\*        | A null-terminated C character  |
    199    |                   |               | array.                         |
    200    +-------------------+---------------+--------------------------------+
    201    | :attr:`%p`        | void\*        | The hex representation of a C  |
    202    |                   |               | pointer. Mostly equivalent to  |
    203    |                   |               | ``printf("%p")`` except that   |
    204    |                   |               | it is guaranteed to start with |
    205    |                   |               | the literal ``0x`` regardless  |
    206    |                   |               | of what the platform's         |
    207    |                   |               | ``printf`` yields.             |
    208    +-------------------+---------------+--------------------------------+
    209 
    210    An unrecognized format character causes all the rest of the format string to be
    211    copied as-is to the result string, and any extra arguments discarded.
    212 
    213 
    214 .. cfunction:: void PyErr_SetNone(PyObject *type)
     152.. c:function:: PyObject* PyErr_Format(PyObject *exception, const char *format, ...)
     153
     154   This function sets the error indicator and returns *NULL*.  *exception*
     155   should be a Python exception class.  The *format* and subsequent
     156   parameters help format the error message; they have the same meaning and
     157   values as in :c:func:`PyString_FromFormat`.
     158
     159
     160.. c:function:: void PyErr_SetNone(PyObject *type)
    215161
    216162   This is a shorthand for ``PyErr_SetObject(type, Py_None)``.
    217163
    218164
    219 .. cfunction:: int PyErr_BadArgument()
     165.. c:function:: int PyErr_BadArgument()
    220166
    221167   This is a shorthand for ``PyErr_SetString(PyExc_TypeError, message)``, where
     
    224170
    225171
    226 .. cfunction:: PyObject* PyErr_NoMemory()
     172.. c:function:: PyObject* PyErr_NoMemory()
    227173
    228174   This is a shorthand for ``PyErr_SetNone(PyExc_MemoryError)``; it returns *NULL*
     
    231177
    232178
    233 .. cfunction:: PyObject* PyErr_SetFromErrno(PyObject *type)
     179.. c:function:: PyObject* PyErr_SetFromErrno(PyObject *type)
    234180
    235181   .. index:: single: strerror()
    236182
    237183   This is a convenience function to raise an exception when a C library function
    238    has returned an error and set the C variable :cdata:`errno`.  It constructs a
    239    tuple object whose first item is the integer :cdata:`errno` value and whose
    240    second item is the corresponding error message (gotten from :cfunc:`strerror`),
     184   has returned an error and set the C variable :c:data:`errno`.  It constructs a
     185   tuple object whose first item is the integer :c:data:`errno` value and whose
     186   second item is the corresponding error message (gotten from :c:func:`strerror`),
    241187   and then calls ``PyErr_SetObject(type, object)``.  On Unix, when the
    242    :cdata:`errno` value is :const:`EINTR`, indicating an interrupted system call,
    243    this calls :cfunc:`PyErr_CheckSignals`, and if that set the error indicator,
     188   :c:data:`errno` value is :const:`EINTR`, indicating an interrupted system call,
     189   this calls :c:func:`PyErr_CheckSignals`, and if that set the error indicator,
    244190   leaves it set to that.  The function always returns *NULL*, so a wrapper
    245191   function around a system call can write ``return PyErr_SetFromErrno(type);``
     
    247193
    248194
    249 .. cfunction:: PyObject* PyErr_SetFromErrnoWithFilename(PyObject *type, const char *filename)
    250 
    251    Similar to :cfunc:`PyErr_SetFromErrno`, with the additional behavior that if
    252    *filename* is not *NULL*, it is passed to the constructor of *type* as a third
    253    parameter.  In the case of exceptions such as :exc:`IOError` and :exc:`OSError`,
    254    this is used to define the :attr:`filename` attribute of the exception instance.
    255 
    256 
    257 .. cfunction:: PyObject* PyErr_SetFromWindowsErr(int ierr)
     195.. c:function:: PyObject* PyErr_SetFromErrnoWithFilenameObject(PyObject *type, PyObject *filenameObject)
     196
     197   Similar to :c:func:`PyErr_SetFromErrno`, with the additional behavior that if
     198   *filenameObject* is not *NULL*, it is passed to the constructor of *type* as
     199   a third parameter.  In the case of exceptions such as :exc:`IOError` and
     200   :exc:`OSError`, this is used to define the :attr:`filename` attribute of the
     201   exception instance.
     202
     203
     204.. c:function:: PyObject* PyErr_SetFromErrnoWithFilename(PyObject *type, const char *filename)
     205
     206   Similar to :c:func:`PyErr_SetFromErrnoWithFilenameObject`, but the filename
     207   is given as a C string.
     208
     209
     210.. c:function:: PyObject* PyErr_SetFromWindowsErr(int ierr)
    258211
    259212   This is a convenience function to raise :exc:`WindowsError`. If called with
    260    *ierr* of :cdata:`0`, the error code returned by a call to :cfunc:`GetLastError`
    261    is used instead.  It calls the Win32 function :cfunc:`FormatMessage` to retrieve
    262    the Windows description of error code given by *ierr* or :cfunc:`GetLastError`,
     213   *ierr* of :c:data:`0`, the error code returned by a call to :c:func:`GetLastError`
     214   is used instead.  It calls the Win32 function :c:func:`FormatMessage` to retrieve
     215   the Windows description of error code given by *ierr* or :c:func:`GetLastError`,
    263216   then it constructs a tuple object whose first item is the *ierr* value and whose
    264217   second item is the corresponding error message (gotten from
    265    :cfunc:`FormatMessage`), and then calls ``PyErr_SetObject(PyExc_WindowsError,
     218   :c:func:`FormatMessage`), and then calls ``PyErr_SetObject(PyExc_WindowsError,
    266219   object)``. This function always returns *NULL*. Availability: Windows.
    267220
    268221
    269 .. cfunction:: PyObject* PyErr_SetExcFromWindowsErr(PyObject *type, int ierr)
    270 
    271    Similar to :cfunc:`PyErr_SetFromWindowsErr`, with an additional parameter
     222.. c:function:: PyObject* PyErr_SetExcFromWindowsErr(PyObject *type, int ierr)
     223
     224   Similar to :c:func:`PyErr_SetFromWindowsErr`, with an additional parameter
    272225   specifying the exception type to be raised. Availability: Windows.
    273226
     
    275228
    276229
    277 .. cfunction:: PyObject* PyErr_SetFromWindowsErrWithFilename(int ierr, const char *filename)
    278 
    279    Similar to :cfunc:`PyErr_SetFromWindowsErr`, with the additional behavior that
    280    if *filename* is not *NULL*, it is passed to the constructor of
     230.. c:function:: PyObject* PyErr_SetFromWindowsErrWithFilenameObject(int ierr, PyObject *filenameObject)
     231
     232   Similar to :c:func:`PyErr_SetFromWindowsErr`, with the additional behavior that
     233   if *filenameObject* is not *NULL*, it is passed to the constructor of
    281234   :exc:`WindowsError` as a third parameter. Availability: Windows.
    282235
    283236
    284 .. cfunction:: PyObject* PyErr_SetExcFromWindowsErrWithFilename(PyObject *type, int ierr, char *filename)
    285 
    286    Similar to :cfunc:`PyErr_SetFromWindowsErrWithFilename`, with an additional
     237.. c:function:: PyObject* PyErr_SetFromWindowsErrWithFilename(int ierr, const char *filename)
     238
     239   Similar to :c:func:`PyErr_SetFromWindowsErrWithFilenameObject`, but the
     240   filename is given as a C string. Availability: Windows.
     241
     242
     243.. c:function:: PyObject* PyErr_SetExcFromWindowsErrWithFilenameObject(PyObject *type, int ierr, PyObject *filename)
     244
     245   Similar to :c:func:`PyErr_SetFromWindowsErrWithFilenameObject`, with an
     246   additional parameter specifying the exception type to be raised.
     247   Availability: Windows.
     248
     249   .. versionadded:: 2.3
     250
     251
     252.. c:function:: PyObject* PyErr_SetExcFromWindowsErrWithFilename(PyObject *type, int ierr, const char *filename)
     253
     254   Similar to :c:func:`PyErr_SetFromWindowsErrWithFilename`, with an additional
    287255   parameter specifying the exception type to be raised. Availability: Windows.
    288256
     
    290258
    291259
    292 .. cfunction:: void PyErr_BadInternalCall()
     260.. c:function:: void PyErr_BadInternalCall()
    293261
    294262   This is a shorthand for ``PyErr_SetString(PyExc_SystemError, message)``,
     
    298266
    299267
    300 .. cfunction:: int PyErr_WarnEx(PyObject *category, char *message, int stacklevel)
     268.. c:function:: int PyErr_WarnEx(PyObject *category, char *message, int stacklevel)
    301269
    302270   Issue a warning message.  The *category* argument is a warning category (see
     
    304272   positive number giving a number of stack frames; the warning will be issued from
    305273   the  currently executing line of code in that stack frame.  A *stacklevel* of 1
    306    is the function calling :cfunc:`PyErr_WarnEx`, 2 is  the function above that,
     274   is the function calling :c:func:`PyErr_WarnEx`, 2 is  the function above that,
    307275   and so forth.
    308276
     
    316284   actually printed, nor what the reason is for the exception; this is
    317285   intentional.)  If an exception is raised, the caller should do its normal
    318    exception handling (for example, :cfunc:`Py_DECREF` owned references and return
     286   exception handling (for example, :c:func:`Py_DECREF` owned references and return
    319287   an error value).
    320288
    321    Warning categories must be subclasses of :cdata:`Warning`; the default warning
    322    category is :cdata:`RuntimeWarning`.  The standard Python warning categories are
     289   Warning categories must be subclasses of :c:data:`Warning`; the default warning
     290   category is :c:data:`RuntimeWarning`.  The standard Python warning categories are
    323291   available as global variables whose names are ``PyExc_`` followed by the Python
    324    exception name. These have the type :ctype:`PyObject\*`; they are all class
    325    objects. Their names are :cdata:`PyExc_Warning`, :cdata:`PyExc_UserWarning`,
    326    :cdata:`PyExc_UnicodeWarning`, :cdata:`PyExc_DeprecationWarning`,
    327    :cdata:`PyExc_SyntaxWarning`, :cdata:`PyExc_RuntimeWarning`, and
    328    :cdata:`PyExc_FutureWarning`.  :cdata:`PyExc_Warning` is a subclass of
    329    :cdata:`PyExc_Exception`; the other warning categories are subclasses of
    330    :cdata:`PyExc_Warning`.
     292   exception name. These have the type :c:type:`PyObject\*`; they are all class
     293   objects. Their names are :c:data:`PyExc_Warning`, :c:data:`PyExc_UserWarning`,
     294   :c:data:`PyExc_UnicodeWarning`, :c:data:`PyExc_DeprecationWarning`,
     295   :c:data:`PyExc_SyntaxWarning`, :c:data:`PyExc_RuntimeWarning`, and
     296   :c:data:`PyExc_FutureWarning`.  :c:data:`PyExc_Warning` is a subclass of
     297   :c:data:`PyExc_Exception`; the other warning categories are subclasses of
     298   :c:data:`PyExc_Warning`.
    331299
    332300   For information about warning control, see the documentation for the
     
    335303
    336304
    337 .. cfunction:: int PyErr_Warn(PyObject *category, char *message)
     305.. c:function:: int PyErr_Warn(PyObject *category, char *message)
    338306
    339307   Issue a warning message.  The *category* argument is a warning category (see
    340308   below) or *NULL*; the *message* argument is a message string.  The warning will
    341    appear to be issued from the function calling :cfunc:`PyErr_Warn`, equivalent to
    342    calling :cfunc:`PyErr_WarnEx` with a *stacklevel* of 1.
    343 
    344    Deprecated; use :cfunc:`PyErr_WarnEx` instead.
    345 
    346 
    347 .. cfunction:: int PyErr_WarnExplicit(PyObject *category, const char *message, const char *filename, int lineno, const char *module, PyObject *registry)
     309   appear to be issued from the function calling :c:func:`PyErr_Warn`, equivalent to
     310   calling :c:func:`PyErr_WarnEx` with a *stacklevel* of 1.
     311
     312   Deprecated; use :c:func:`PyErr_WarnEx` instead.
     313
     314
     315.. c:function:: int PyErr_WarnExplicit(PyObject *category, const char *message, const char *filename, int lineno, const char *module, PyObject *registry)
    348316
    349317   Issue a warning message with explicit control over all warning attributes.  This
     
    354322
    355323
    356 .. cfunction:: int PyErr_WarnPy3k(char *message, int stacklevel)
     324.. c:function:: int PyErr_WarnPy3k(char *message, int stacklevel)
    357325
    358326   Issue a :exc:`DeprecationWarning` with the given *message* and *stacklevel*
    359    if the :cdata:`Py_Py3kWarningFlag` flag is enabled.
     327   if the :c:data:`Py_Py3kWarningFlag` flag is enabled.
    360328
    361329   .. versionadded:: 2.6
    362330
    363331
    364 .. cfunction:: int PyErr_CheckSignals()
     332.. c:function:: int PyErr_CheckSignals()
    365333
    366334   .. index::
     
    379347
    380348
    381 .. cfunction:: void PyErr_SetInterrupt()
     349.. c:function:: void PyErr_SetInterrupt()
    382350
    383351   .. index::
     
    386354
    387355   This function simulates the effect of a :const:`SIGINT` signal arriving --- the
    388    next time :cfunc:`PyErr_CheckSignals` is called,  :exc:`KeyboardInterrupt` will
     356   next time :c:func:`PyErr_CheckSignals` is called,  :exc:`KeyboardInterrupt` will
    389357   be raised.  It may be called without holding the interpreter lock.
    390358
     
    393361
    394362
    395 .. cfunction:: int PySignal_SetWakeupFd(int fd)
     363.. c:function:: int PySignal_SetWakeupFd(int fd)
    396364
    397365   This utility function specifies a file descriptor to which a ``'\0'`` byte will
     
    402370   only be called from the main thread.
    403371
    404 
    405 .. cfunction:: PyObject* PyErr_NewException(char *name, PyObject *base, PyObject *dict)
    406 
    407    This utility function creates and returns a new exception object. The *name*
     372   .. versionadded:: 2.6
     373
     374
     375.. c:function:: PyObject* PyErr_NewException(char *name, PyObject *base, PyObject *dict)
     376
     377   This utility function creates and returns a new exception class. The *name*
    408378   argument must be the name of the new exception, a C string of the form
    409    ``module.class``.  The *base* and *dict* arguments are normally *NULL*.  This
    410    creates a class object derived from :exc:`Exception` (accessible in C as
    411    :cdata:`PyExc_Exception`).
     379   ``module.classname``.  The *base* and *dict* arguments are normally *NULL*.
     380   This creates a class object derived from :exc:`Exception` (accessible in C as
     381   :c:data:`PyExc_Exception`).
    412382
    413383   The :attr:`__module__` attribute of the new class is set to the first part (up
     
    418388
    419389
    420 .. cfunction:: void PyErr_WriteUnraisable(PyObject *obj)
     390.. c:function:: PyObject* PyErr_NewExceptionWithDoc(char *name, char *doc, PyObject *base, PyObject *dict)
     391
     392   Same as :c:func:`PyErr_NewException`, except that the new exception class can
     393   easily be given a docstring: If *doc* is non-*NULL*, it will be used as the
     394   docstring for the exception class.
     395
     396   .. versionadded:: 2.7
     397
     398
     399.. c:function:: void PyErr_WriteUnraisable(PyObject *obj)
    421400
    422401   This utility function prints a warning message to ``sys.stderr`` when an
     
    430409
    431410
     411.. _unicodeexceptions:
     412
     413Unicode Exception Objects
     414=========================
     415
     416The following functions are used to create and modify Unicode exceptions from C.
     417
     418.. c:function:: PyObject* PyUnicodeDecodeError_Create(const char *encoding, const char *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
     419
     420   Create a :class:`UnicodeDecodeError` object with the attributes *encoding*,
     421   *object*, *length*, *start*, *end* and *reason*.
     422
     423.. c:function:: PyObject* PyUnicodeEncodeError_Create(const char *encoding, const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
     424
     425   Create a :class:`UnicodeEncodeError` object with the attributes *encoding*,
     426   *object*, *length*, *start*, *end* and *reason*.
     427
     428.. c:function:: PyObject* PyUnicodeTranslateError_Create(const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
     429
     430   Create a :class:`UnicodeTranslateError` object with the attributes *object*,
     431   *length*, *start*, *end* and *reason*.
     432
     433.. c:function:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc)
     434               PyObject* PyUnicodeEncodeError_GetEncoding(PyObject *exc)
     435
     436   Return the *encoding* attribute of the given exception object.
     437
     438.. c:function:: PyObject* PyUnicodeDecodeError_GetObject(PyObject *exc)
     439               PyObject* PyUnicodeEncodeError_GetObject(PyObject *exc)
     440               PyObject* PyUnicodeTranslateError_GetObject(PyObject *exc)
     441
     442   Return the *object* attribute of the given exception object.
     443
     444.. c:function:: int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start)
     445               int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start)
     446               int PyUnicodeTranslateError_GetStart(PyObject *exc, Py_ssize_t *start)
     447
     448   Get the *start* attribute of the given exception object and place it into
     449   *\*start*.  *start* must not be *NULL*.  Return ``0`` on success, ``-1`` on
     450   failure.
     451
     452.. c:function:: int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start)
     453               int PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start)
     454               int PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start)
     455
     456   Set the *start* attribute of the given exception object to *start*.  Return
     457   ``0`` on success, ``-1`` on failure.
     458
     459.. c:function:: int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
     460               int PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
     461               int PyUnicodeTranslateError_GetEnd(PyObject *exc, Py_ssize_t *end)
     462
     463   Get the *end* attribute of the given exception object and place it into
     464   *\*end*.  *end* must not be *NULL*.  Return ``0`` on success, ``-1`` on
     465   failure.
     466
     467.. c:function:: int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end)
     468               int PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end)
     469               int PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end)
     470
     471   Set the *end* attribute of the given exception object to *end*.  Return ``0``
     472   on success, ``-1`` on failure.
     473
     474.. c:function:: PyObject* PyUnicodeDecodeError_GetReason(PyObject *exc)
     475               PyObject* PyUnicodeEncodeError_GetReason(PyObject *exc)
     476               PyObject* PyUnicodeTranslateError_GetReason(PyObject *exc)
     477
     478   Return the *reason* attribute of the given exception object.
     479
     480.. c:function:: int PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason)
     481               int PyUnicodeEncodeError_SetReason(PyObject *exc, const char *reason)
     482               int PyUnicodeTranslateError_SetReason(PyObject *exc, const char *reason)
     483
     484   Set the *reason* attribute of the given exception object to *reason*.  Return
     485   ``0`` on success, ``-1`` on failure.
     486
     487
     488Recursion Control
     489=================
     490
     491These two functions provide a way to perform safe recursive calls at the C
     492level, both in the core and in extension modules.  They are needed if the
     493recursive code does not necessarily invoke Python code (which tracks its
     494recursion depth automatically).
     495
     496.. c:function:: int Py_EnterRecursiveCall(char *where)
     497
     498   Marks a point where a recursive C-level call is about to be performed.
     499
     500   If :const:`USE_STACKCHECK` is defined, this function checks if the OS
     501   stack overflowed using :c:func:`PyOS_CheckStack`.  In this is the case, it
     502   sets a :exc:`MemoryError` and returns a nonzero value.
     503
     504   The function then checks if the recursion limit is reached.  If this is the
     505   case, a :exc:`RuntimeError` is set and a nonzero value is returned.
     506   Otherwise, zero is returned.
     507
     508   *where* should be a string such as ``" in instance check"`` to be
     509   concatenated to the :exc:`RuntimeError` message caused by the recursion depth
     510   limit.
     511
     512.. c:function:: void Py_LeaveRecursiveCall()
     513
     514   Ends a :c:func:`Py_EnterRecursiveCall`.  Must be called once for each
     515   *successful* invocation of :c:func:`Py_EnterRecursiveCall`.
     516
     517
    432518.. _standardexceptions:
    433519
     
    437523All standard Python exceptions are available as global variables whose names are
    438524``PyExc_`` followed by the Python exception name.  These have the type
    439 :ctype:`PyObject\*`; they are all class objects.  For completeness, here are all
     525:c:type:`PyObject\*`; they are all class objects.  For completeness, here are all
    440526the variables:
    441527
    442 +------------------------------------+----------------------------+----------+
    443 | C Name                             | Python Name                | Notes    |
    444 +====================================+============================+==========+
    445 | :cdata:`PyExc_BaseException`       | :exc:`BaseException`       | (1), (4) |
    446 +------------------------------------+----------------------------+----------+
    447 | :cdata:`PyExc_Exception`           | :exc:`Exception`           | \(1)     |
    448 +------------------------------------+----------------------------+----------+
    449 | :cdata:`PyExc_StandardError`       | :exc:`StandardError`       | \(1)     |
    450 +------------------------------------+----------------------------+----------+
    451 | :cdata:`PyExc_ArithmeticError`     | :exc:`ArithmeticError`     | \(1)     |
    452 +------------------------------------+----------------------------+----------+
    453 | :cdata:`PyExc_LookupError`         | :exc:`LookupError`         | \(1)     |
    454 +------------------------------------+----------------------------+----------+
    455 | :cdata:`PyExc_AssertionError`      | :exc:`AssertionError`      |          |
    456 +------------------------------------+----------------------------+----------+
    457 | :cdata:`PyExc_AttributeError`      | :exc:`AttributeError`      |          |
    458 +------------------------------------+----------------------------+----------+
    459 | :cdata:`PyExc_EOFError`            | :exc:`EOFError`            |          |
    460 +------------------------------------+----------------------------+----------+
    461 | :cdata:`PyExc_EnvironmentError`    | :exc:`EnvironmentError`    | \(1)     |
    462 +------------------------------------+----------------------------+----------+
    463 | :cdata:`PyExc_FloatingPointError`  | :exc:`FloatingPointError`  |          |
    464 +------------------------------------+----------------------------+----------+
    465 | :cdata:`PyExc_IOError`             | :exc:`IOError`             |          |
    466 +------------------------------------+----------------------------+----------+
    467 | :cdata:`PyExc_ImportError`         | :exc:`ImportError`         |          |
    468 +------------------------------------+----------------------------+----------+
    469 | :cdata:`PyExc_IndexError`          | :exc:`IndexError`          |          |
    470 +------------------------------------+----------------------------+----------+
    471 | :cdata:`PyExc_KeyError`            | :exc:`KeyError`            |          |
    472 +------------------------------------+----------------------------+----------+
    473 | :cdata:`PyExc_KeyboardInterrupt`   | :exc:`KeyboardInterrupt`   |          |
    474 +------------------------------------+----------------------------+----------+
    475 | :cdata:`PyExc_MemoryError`         | :exc:`MemoryError`         |          |
    476 +------------------------------------+----------------------------+----------+
    477 | :cdata:`PyExc_NameError`           | :exc:`NameError`           |          |
    478 +------------------------------------+----------------------------+----------+
    479 | :cdata:`PyExc_NotImplementedError` | :exc:`NotImplementedError` |          |
    480 +------------------------------------+----------------------------+----------+
    481 | :cdata:`PyExc_OSError`             | :exc:`OSError`             |          |
    482 +------------------------------------+----------------------------+----------+
    483 | :cdata:`PyExc_OverflowError`       | :exc:`OverflowError`       |          |
    484 +------------------------------------+----------------------------+----------+
    485 | :cdata:`PyExc_ReferenceError`      | :exc:`ReferenceError`      | \(2)     |
    486 +------------------------------------+----------------------------+----------+
    487 | :cdata:`PyExc_RuntimeError`        | :exc:`RuntimeError`        |          |
    488 +------------------------------------+----------------------------+----------+
    489 | :cdata:`PyExc_SyntaxError`         | :exc:`SyntaxError`         |          |
    490 +------------------------------------+----------------------------+----------+
    491 | :cdata:`PyExc_SystemError`         | :exc:`SystemError`         |          |
    492 +------------------------------------+----------------------------+----------+
    493 | :cdata:`PyExc_SystemExit`          | :exc:`SystemExit`          |          |
    494 +------------------------------------+----------------------------+----------+
    495 | :cdata:`PyExc_TypeError`           | :exc:`TypeError`           |          |
    496 +------------------------------------+----------------------------+----------+
    497 | :cdata:`PyExc_ValueError`          | :exc:`ValueError`          |          |
    498 +------------------------------------+----------------------------+----------+
    499 | :cdata:`PyExc_WindowsError`        | :exc:`WindowsError`        | \(3)     |
    500 +------------------------------------+----------------------------+----------+
    501 | :cdata:`PyExc_ZeroDivisionError`   | :exc:`ZeroDivisionError`   |          |
    502 +------------------------------------+----------------------------+----------+
     528+-------------------------------------+----------------------------+----------+
     529| C Name                              | Python Name                | Notes    |
     530+=====================================+============================+==========+
     531| :c:data:`PyExc_BaseException`       | :exc:`BaseException`       | (1), (4) |
     532+-------------------------------------+----------------------------+----------+
     533| :c:data:`PyExc_Exception`           | :exc:`Exception`           | \(1)     |
     534+-------------------------------------+----------------------------+----------+
     535| :c:data:`PyExc_StandardError`       | :exc:`StandardError`       | \(1)     |
     536+-------------------------------------+----------------------------+----------+
     537| :c:data:`PyExc_ArithmeticError`     | :exc:`ArithmeticError`     | \(1)     |
     538+-------------------------------------+----------------------------+----------+
     539| :c:data:`PyExc_LookupError`         | :exc:`LookupError`         | \(1)     |
     540+-------------------------------------+----------------------------+----------+
     541| :c:data:`PyExc_AssertionError`      | :exc:`AssertionError`      |          |
     542+-------------------------------------+----------------------------+----------+
     543| :c:data:`PyExc_AttributeError`      | :exc:`AttributeError`      |          |
     544+-------------------------------------+----------------------------+----------+
     545| :c:data:`PyExc_EOFError`            | :exc:`EOFError`            |          |
     546+-------------------------------------+----------------------------+----------+
     547| :c:data:`PyExc_EnvironmentError`    | :exc:`EnvironmentError`    | \(1)     |
     548+-------------------------------------+----------------------------+----------+
     549| :c:data:`PyExc_FloatingPointError`  | :exc:`FloatingPointError`  |          |
     550+-------------------------------------+----------------------------+----------+
     551| :c:data:`PyExc_IOError`             | :exc:`IOError`             |          |
     552+-------------------------------------+----------------------------+----------+
     553| :c:data:`PyExc_ImportError`         | :exc:`ImportError`         |          |
     554+-------------------------------------+----------------------------+----------+
     555| :c:data:`PyExc_IndexError`          | :exc:`IndexError`          |          |
     556+-------------------------------------+----------------------------+----------+
     557| :c:data:`PyExc_KeyError`            | :exc:`KeyError`            |          |
     558+-------------------------------------+----------------------------+----------+
     559| :c:data:`PyExc_KeyboardInterrupt`   | :exc:`KeyboardInterrupt`   |          |
     560+-------------------------------------+----------------------------+----------+
     561| :c:data:`PyExc_MemoryError`         | :exc:`MemoryError`         |          |
     562+-------------------------------------+----------------------------+----------+
     563| :c:data:`PyExc_NameError`           | :exc:`NameError`           |          |
     564+-------------------------------------+----------------------------+----------+
     565| :c:data:`PyExc_NotImplementedError` | :exc:`NotImplementedError` |          |
     566+-------------------------------------+----------------------------+----------+
     567| :c:data:`PyExc_OSError`             | :exc:`OSError`             |          |
     568+-------------------------------------+----------------------------+----------+
     569| :c:data:`PyExc_OverflowError`       | :exc:`OverflowError`       |          |
     570+-------------------------------------+----------------------------+----------+
     571| :c:data:`PyExc_ReferenceError`      | :exc:`ReferenceError`      | \(2)     |
     572+-------------------------------------+----------------------------+----------+
     573| :c:data:`PyExc_RuntimeError`        | :exc:`RuntimeError`        |          |
     574+-------------------------------------+----------------------------+----------+
     575| :c:data:`PyExc_SyntaxError`         | :exc:`SyntaxError`         |          |
     576+-------------------------------------+----------------------------+----------+
     577| :c:data:`PyExc_SystemError`         | :exc:`SystemError`         |          |
     578+-------------------------------------+----------------------------+----------+
     579| :c:data:`PyExc_SystemExit`          | :exc:`SystemExit`          |          |
     580+-------------------------------------+----------------------------+----------+
     581| :c:data:`PyExc_TypeError`           | :exc:`TypeError`           |          |
     582+-------------------------------------+----------------------------+----------+
     583| :c:data:`PyExc_ValueError`          | :exc:`ValueError`          |          |
     584+-------------------------------------+----------------------------+----------+
     585| :c:data:`PyExc_WindowsError`        | :exc:`WindowsError`        | \(3)     |
     586+-------------------------------------+----------------------------+----------+
     587| :c:data:`PyExc_ZeroDivisionError`   | :exc:`ZeroDivisionError`   |          |
     588+-------------------------------------+----------------------------+----------+
    503589
    504590.. index::
     
    549635
    550636
    551 Deprecation of String Exceptions
    552 ================================
    553 
    554 .. index:: single: BaseException (built-in exception)
    555 
    556 All exceptions built into Python or provided in the standard library are derived
    557 from :exc:`BaseException`.
    558 
    559 String exceptions are still supported in the interpreter to allow existing code
    560 to run unmodified, but this will also change in a future release.
    561 
     637String Exceptions
     638=================
     639
     640.. versionchanged:: 2.6
     641   All exceptions to be raised or caught must be derived from :exc:`BaseException`.
     642   Trying to raise a string exception now raises :exc:`TypeError`.
     643
  • python/vendor/current/Doc/c-api/file.rst

    r2 r388  
    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
  • python/vendor/current/Doc/c-api/float.rst

    r2 r388  
    99
    1010
    11 .. ctype:: PyFloatObject
     11.. c:type:: PyFloatObject
    1212
    13    This subtype of :ctype:`PyObject` represents a Python floating point object.
     13   This subtype of :c:type:`PyObject` represents a Python floating point object.
    1414
    1515
    16 .. cvar:: PyTypeObject PyFloat_Type
     16.. c:var:: PyTypeObject PyFloat_Type
    1717
    1818   .. index:: single: FloatType (in modules types)
    1919
    20    This instance of :ctype:`PyTypeObject` represents the Python floating point
     20   This instance of :c:type:`PyTypeObject` represents the Python floating point
    2121   type.  This is the same object as ``float`` and ``types.FloatType``.
    2222
    2323
    24 .. cfunction:: int PyFloat_Check(PyObject *p)
     24.. c:function:: int PyFloat_Check(PyObject *p)
    2525
    26    Return true if its argument is a :ctype:`PyFloatObject` or a subtype of
    27    :ctype:`PyFloatObject`.
     26   Return true if its argument is a :c:type:`PyFloatObject` or a subtype of
     27   :c:type:`PyFloatObject`.
    2828
    2929   .. versionchanged:: 2.2
     
    3131
    3232
    33 .. cfunction:: int PyFloat_CheckExact(PyObject *p)
     33.. c:function:: int PyFloat_CheckExact(PyObject *p)
    3434
    35    Return true if its argument is a :ctype:`PyFloatObject`, but not a subtype of
    36    :ctype:`PyFloatObject`.
     35   Return true if its argument is a :c:type:`PyFloatObject`, but not a subtype of
     36   :c:type:`PyFloatObject`.
    3737
    3838   .. versionadded:: 2.2
    3939
    4040
    41 .. cfunction:: PyObject* PyFloat_FromString(PyObject *str, char **pend)
     41.. c:function:: PyObject* PyFloat_FromString(PyObject *str, char **pend)
    4242
    43    Create a :ctype:`PyFloatObject` object based on the string value in *str*, or
     43   Create a :c:type:`PyFloatObject` object based on the string value in *str*, or
    4444   *NULL* on failure.  The *pend* argument is ignored.  It remains only for
    4545   backward compatibility.
    4646
    4747
    48 .. cfunction:: PyObject* PyFloat_FromDouble(double v)
     48.. c:function:: PyObject* PyFloat_FromDouble(double v)
    4949
    50    Create a :ctype:`PyFloatObject` object from *v*, or *NULL* on failure.
     50   Create a :c:type:`PyFloatObject` object from *v*, or *NULL* on failure.
    5151
    5252
    53 .. cfunction:: double PyFloat_AsDouble(PyObject *pyfloat)
     53.. c:function:: double PyFloat_AsDouble(PyObject *pyfloat)
    5454
    55    Return a C :ctype:`double` representation of the contents of *pyfloat*.  If
     55   Return a C :c:type:`double` representation of the contents of *pyfloat*.  If
    5656   *pyfloat* is not a Python floating point object but has a :meth:`__float__`
    5757   method, this method will first be called to convert *pyfloat* into a float.
     58   This method returns ``-1.0`` upon failure, so one should call
     59   :c:func:`PyErr_Occurred` to check for errors.
    5860
    5961
    60 .. cfunction:: double PyFloat_AS_DOUBLE(PyObject *pyfloat)
     62.. c:function:: double PyFloat_AS_DOUBLE(PyObject *pyfloat)
    6163
    62    Return a C :ctype:`double` representation of the contents of *pyfloat*, but
     64   Return a C :c:type:`double` representation of the contents of *pyfloat*, but
    6365   without error checking.
    6466
    6567
    66 .. cfunction:: PyObject* PyFloat_GetInfo(void)
     68.. c:function:: PyObject* PyFloat_GetInfo(void)
    6769
    6870   Return a structseq instance which contains information about the
     
    7375
    7476
    75 .. cfunction:: double PyFloat_GetMax()
     77.. c:function:: double PyFloat_GetMax()
    7678
    77    Return the maximum representable finite float *DBL_MAX* as C :ctype:`double`.
     79   Return the maximum representable finite float *DBL_MAX* as C :c:type:`double`.
    7880
    7981   .. versionadded:: 2.6
    8082
    8183
    82 .. cfunction:: double PyFloat_GetMin()
     84.. c:function:: double PyFloat_GetMin()
    8385
    84    Return the minimum normalized positive float *DBL_MIN* as C :ctype:`double`.
     86   Return the minimum normalized positive float *DBL_MIN* as C :c:type:`double`.
    8587
    8688   .. versionadded:: 2.6
    8789
    8890
    89 .. cfunction:: int PyFloat_ClearFreeList()
     91.. c:function:: int PyFloat_ClearFreeList()
    9092
    9193   Clear the float free list. Return the number of items that could not
     
    9395
    9496   .. versionadded:: 2.6
     97
     98
     99.. c:function:: void PyFloat_AsString(char *buf, PyFloatObject *v)
     100
     101   Convert the argument *v* to a string, using the same rules as
     102   :func:`str`. The length of *buf* should be at least 100.
     103
     104   This function is unsafe to call because it writes to a buffer whose
     105   length it does not know.
     106
     107   .. deprecated:: 2.7
     108      Use :func:`PyObject_Str` or :func:`PyOS_double_to_string` instead.
     109
     110
     111.. c:function:: void PyFloat_AsReprString(char *buf, PyFloatObject *v)
     112
     113   Same as PyFloat_AsString, except uses the same rules as
     114   :func:`repr`.  The length of *buf* should be at least 100.
     115
     116   This function is unsafe to call because it writes to a buffer whose
     117   length it does not know.
     118
     119   .. deprecated:: 2.7
     120      Use :func:`PyObject_Repr` or :func:`PyOS_double_to_string` instead.
  • python/vendor/current/Doc/c-api/function.rst

    r2 r388  
    1111
    1212
    13 .. ctype:: PyFunctionObject
     13.. c:type:: PyFunctionObject
    1414
    1515   The C structure used for functions.
    1616
    1717
    18 .. cvar:: PyTypeObject PyFunction_Type
     18.. c:var:: PyTypeObject PyFunction_Type
    1919
    2020   .. index:: single: MethodType (in module types)
    2121
    22    This is an instance of :ctype:`PyTypeObject` and represents the Python function
     22   This is an instance of :c:type:`PyTypeObject` and represents the Python function
    2323   type.  It is exposed to Python programmers as ``types.FunctionType``.
    2424
    2525
    26 .. cfunction:: int PyFunction_Check(PyObject *o)
     26.. c:function:: int PyFunction_Check(PyObject *o)
    2727
    28    Return true if *o* is a function object (has type :cdata:`PyFunction_Type`).
     28   Return true if *o* is a function object (has type :c:data:`PyFunction_Type`).
    2929   The parameter must not be *NULL*.
    3030
    3131
    32 .. cfunction:: PyObject* PyFunction_New(PyObject *code, PyObject *globals)
     32.. c:function:: PyObject* PyFunction_New(PyObject *code, PyObject *globals)
    3333
    3434   Return a new function object associated with the code object *code*. *globals*
     
    3939
    4040
    41 .. cfunction:: PyObject* PyFunction_GetCode(PyObject *op)
     41.. c:function:: PyObject* PyFunction_GetCode(PyObject *op)
    4242
    4343   Return the code object associated with the function object *op*.
    4444
    4545
    46 .. cfunction:: PyObject* PyFunction_GetGlobals(PyObject *op)
     46.. c:function:: PyObject* PyFunction_GetGlobals(PyObject *op)
    4747
    4848   Return the globals dictionary associated with the function object *op*.
    4949
    5050
    51 .. cfunction:: PyObject* PyFunction_GetModule(PyObject *op)
     51.. c:function:: PyObject* PyFunction_GetModule(PyObject *op)
    5252
    5353   Return the *__module__* attribute of the function object *op*. This is normally
     
    5656
    5757
    58 .. cfunction:: PyObject* PyFunction_GetDefaults(PyObject *op)
     58.. c:function:: PyObject* PyFunction_GetDefaults(PyObject *op)
    5959
    6060   Return the argument default values of the function object *op*. This can be a
     
    6262
    6363
    64 .. cfunction:: int PyFunction_SetDefaults(PyObject *op, PyObject *defaults)
     64.. c:function:: int PyFunction_SetDefaults(PyObject *op, PyObject *defaults)
    6565
    6666   Set the argument default values for the function object *op*. *defaults* must be
     
    7070
    7171
    72 .. cfunction:: PyObject* PyFunction_GetClosure(PyObject *op)
     72.. c:function:: PyObject* PyFunction_GetClosure(PyObject *op)
    7373
    7474   Return the closure associated with the function object *op*. This can be *NULL*
     
    7676
    7777
    78 .. cfunction:: int PyFunction_SetClosure(PyObject *op, PyObject *closure)
     78.. c:function:: int PyFunction_SetClosure(PyObject *op, PyObject *closure)
    7979
    8080   Set the closure associated with the function object *op*. *closure* must be
  • python/vendor/current/Doc/c-api/gcsupport.rst

    r2 r388  
    1616.. Cycle Collector (XXX not found: ../ext/example-cycle-support.html)".
    1717
    18 To create a container type, the :attr:`tp_flags` field of the type object must
     18To create a container type, the :c:member:`~PyTypeObject.tp_flags` field of the type object must
    1919include the :const:`Py_TPFLAGS_HAVE_GC` and provide an implementation of the
    20 :attr:`tp_traverse` handler.  If instances of the type are mutable, a
    21 :attr:`tp_clear` implementation must also be provided.
     20:c:member:`~PyTypeObject.tp_traverse` handler.  If instances of the type are mutable, a
     21:c:member:`~PyTypeObject.tp_clear` implementation must also be provided.
    2222
    2323
     
    3131Constructors for container types must conform to two rules:
    3232
    33 #. The memory for the object must be allocated using :cfunc:`PyObject_GC_New`
    34    or :cfunc:`PyObject_GC_VarNew`.
     33#. The memory for the object must be allocated using :c:func:`PyObject_GC_New`
     34   or :c:func:`PyObject_GC_NewVar`.
    3535
    3636#. Once all the fields which may contain references to other containers are
    37    initialized, it must call :cfunc:`PyObject_GC_Track`.
     37   initialized, it must call :c:func:`PyObject_GC_Track`.
    3838
    3939
    40 .. cfunction:: TYPE* PyObject_GC_New(TYPE, PyTypeObject *type)
     40.. c:function:: TYPE* PyObject_GC_New(TYPE, PyTypeObject *type)
    4141
    42    Analogous to :cfunc:`PyObject_New` but for container objects with the
     42   Analogous to :c:func:`PyObject_New` but for container objects with the
    4343   :const:`Py_TPFLAGS_HAVE_GC` flag set.
    4444
    4545
    46 .. cfunction:: TYPE* PyObject_GC_NewVar(TYPE, PyTypeObject *type, Py_ssize_t size)
     46.. c:function:: TYPE* PyObject_GC_NewVar(TYPE, PyTypeObject *type, Py_ssize_t size)
    4747
    48    Analogous to :cfunc:`PyObject_NewVar` but for container objects with the
     48   Analogous to :c:func:`PyObject_NewVar` but for container objects with the
    4949   :const:`Py_TPFLAGS_HAVE_GC` flag set.
    5050
    5151   .. versionchanged:: 2.5
    52       This function used an :ctype:`int` type for *size*. This might require
     52      This function used an :c:type:`int` type for *size*. This might require
    5353      changes in your code for properly supporting 64-bit systems.
    5454
    5555
    56 .. cfunction:: TYPE* PyObject_GC_Resize(TYPE, PyVarObject *op, Py_ssize_t newsize)
     56.. c:function:: TYPE* PyObject_GC_Resize(TYPE, PyVarObject *op, Py_ssize_t newsize)
    5757
    58    Resize an object allocated by :cfunc:`PyObject_NewVar`.  Returns the
     58   Resize an object allocated by :c:func:`PyObject_NewVar`.  Returns the
    5959   resized object or *NULL* on failure.
    6060
    6161   .. versionchanged:: 2.5
    62       This function used an :ctype:`int` type for *newsize*. This might
     62      This function used an :c:type:`int` type for *newsize*. This might
    6363      require changes in your code for properly supporting 64-bit systems.
    6464
    6565
    66 .. cfunction:: void PyObject_GC_Track(PyObject *op)
     66.. c:function:: void PyObject_GC_Track(PyObject *op)
    6767
    6868   Adds the object *op* to the set of container objects tracked by the
    6969   collector.  The collector can run at unexpected times so objects must be
    7070   valid while being tracked.  This should be called once all the fields
    71    followed by the :attr:`tp_traverse` handler become valid, usually near the
     71   followed by the :c:member:`~PyTypeObject.tp_traverse` handler become valid, usually near the
    7272   end of the constructor.
    7373
    7474
    75 .. cfunction:: void _PyObject_GC_TRACK(PyObject *op)
     75.. c:function:: void _PyObject_GC_TRACK(PyObject *op)
    7676
    77    A macro version of :cfunc:`PyObject_GC_Track`.  It should not be used for
     77   A macro version of :c:func:`PyObject_GC_Track`.  It should not be used for
    7878   extension modules.
    7979
     
    8282
    8383#. Before fields which refer to other containers are invalidated,
    84    :cfunc:`PyObject_GC_UnTrack` must be called.
     84   :c:func:`PyObject_GC_UnTrack` must be called.
    8585
    86 #. The object's memory must be deallocated using :cfunc:`PyObject_GC_Del`.
     86#. The object's memory must be deallocated using :c:func:`PyObject_GC_Del`.
    8787
    8888
    89 .. cfunction:: void PyObject_GC_Del(void *op)
     89.. c:function:: void PyObject_GC_Del(void *op)
    9090
    91    Releases memory allocated to an object using :cfunc:`PyObject_GC_New` or
    92    :cfunc:`PyObject_GC_NewVar`.
     91   Releases memory allocated to an object using :c:func:`PyObject_GC_New` or
     92   :c:func:`PyObject_GC_NewVar`.
    9393
    9494
    95 .. cfunction:: void PyObject_GC_UnTrack(void *op)
     95.. c:function:: void PyObject_GC_UnTrack(void *op)
    9696
    9797   Remove the object *op* from the set of container objects tracked by the
    98    collector.  Note that :cfunc:`PyObject_GC_Track` can be called again on
     98   collector.  Note that :c:func:`PyObject_GC_Track` can be called again on
    9999   this object to add it back to the set of tracked objects.  The deallocator
    100    (:attr:`tp_dealloc` handler) should call this for the object before any of
    101    the fields used by the :attr:`tp_traverse` handler become invalid.
     100   (:c:member:`~PyTypeObject.tp_dealloc` handler) should call this for the object before any of
     101   the fields used by the :c:member:`~PyTypeObject.tp_traverse` handler become invalid.
    102102
    103103
    104 .. cfunction:: void _PyObject_GC_UNTRACK(PyObject *op)
     104.. c:function:: void _PyObject_GC_UNTRACK(PyObject *op)
    105105
    106    A macro version of :cfunc:`PyObject_GC_UnTrack`.  It should not be used for
     106   A macro version of :c:func:`PyObject_GC_UnTrack`.  It should not be used for
    107107   extension modules.
    108108
    109 The :attr:`tp_traverse` handler accepts a function parameter of this type:
     109The :c:member:`~PyTypeObject.tp_traverse` handler accepts a function parameter of this type:
    110110
    111111
    112 .. ctype:: int (*visitproc)(PyObject *object, void *arg)
     112.. c:type:: int (*visitproc)(PyObject *object, void *arg)
    113113
    114    Type of the visitor function passed to the :attr:`tp_traverse` handler.
     114   Type of the visitor function passed to the :c:member:`~PyTypeObject.tp_traverse` handler.
    115115   The function should be called with an object to traverse as *object* and
    116    the third parameter to the :attr:`tp_traverse` handler as *arg*.  The
     116   the third parameter to the :c:member:`~PyTypeObject.tp_traverse` handler as *arg*.  The
    117117   Python core uses several visitor functions to implement cyclic garbage
    118118   detection; it's not expected that users will need to write their own
    119119   visitor functions.
    120120
    121 The :attr:`tp_traverse` handler must have the following type:
     121The :c:member:`~PyTypeObject.tp_traverse` handler must have the following type:
    122122
    123123
    124 .. ctype:: int (*traverseproc)(PyObject *self, visitproc visit, void *arg)
     124.. c:type:: int (*traverseproc)(PyObject *self, visitproc visit, void *arg)
    125125
    126126   Traversal function for a container object.  Implementations must call the
     
    131131   returned immediately.
    132132
    133 To simplify writing :attr:`tp_traverse` handlers, a :cfunc:`Py_VISIT` macro is
    134 provided.  In order to use this macro, the :attr:`tp_traverse` implementation
     133To simplify writing :c:member:`~PyTypeObject.tp_traverse` handlers, a :c:func:`Py_VISIT` macro is
     134provided.  In order to use this macro, the :c:member:`~PyTypeObject.tp_traverse` implementation
    135135must name its arguments exactly *visit* and *arg*:
    136136
    137137
    138 .. cfunction:: void Py_VISIT(PyObject *o)
     138.. c:function:: void Py_VISIT(PyObject *o)
    139139
    140140   Call the *visit* callback, with arguments *o* and *arg*. If *visit* returns
    141    a non-zero value, then return it.  Using this macro, :attr:`tp_traverse`
     141   a non-zero value, then return it.  Using this macro, :c:member:`~PyTypeObject.tp_traverse`
    142142   handlers look like::
    143143
     
    152152   .. versionadded:: 2.4
    153153
    154 The :attr:`tp_clear` handler must be of the :ctype:`inquiry` type, or *NULL*
     154The :c:member:`~PyTypeObject.tp_clear` handler must be of the :c:type:`inquiry` type, or *NULL*
    155155if the object is immutable.
    156156
    157157
    158 .. ctype:: int (*inquiry)(PyObject *self)
     158.. c:type:: int (*inquiry)(PyObject *self)
    159159
    160160   Drop references that may have created reference cycles.  Immutable objects
    161161   do not have to define this method since they can never directly create
    162162   reference cycles.  Note that the object must still be valid after calling
    163    this method (don't just call :cfunc:`Py_DECREF` on a reference).  The
     163   this method (don't just call :c:func:`Py_DECREF` on a reference).  The
    164164   collector will call this method if it detects that this object is involved
    165165   in a reference cycle.
  • python/vendor/current/Doc/c-api/gen.rst

    r2 r388  
    88Generator objects are what Python uses to implement generator iterators. They
    99are normally created by iterating over a function that yields values, rather
    10 than explicitly calling :cfunc:`PyGen_New`.
     10than explicitly calling :c:func:`PyGen_New`.
    1111
    1212
    13 .. ctype:: PyGenObject
     13.. c:type:: PyGenObject
    1414
    1515   The C structure used for generator objects.
    1616
    1717
    18 .. cvar:: PyTypeObject PyGen_Type
     18.. c:var:: PyTypeObject PyGen_Type
    1919
    2020   The type object corresponding to generator objects
    2121
    2222
    23 .. cfunction:: int PyGen_Check(ob)
     23.. c:function:: int PyGen_Check(ob)
    2424
    2525   Return true if *ob* is a generator object; *ob* must not be *NULL*.
    2626
    2727
    28 .. cfunction:: int PyGen_CheckExact(ob)
     28.. c:function:: int PyGen_CheckExact(ob)
    2929
    3030   Return true if *ob*'s type is *PyGen_Type* is a generator object; *ob* must not
     
    3232
    3333
    34 .. cfunction:: PyObject* PyGen_New(PyFrameObject *frame)
     34.. c:function:: PyObject* PyGen_New(PyFrameObject *frame)
    3535
    3636   Create and return a new generator object based on the *frame* object. A
  • python/vendor/current/Doc/c-api/import.rst

    r2 r388  
    77
    88
    9 .. cfunction:: PyObject* PyImport_ImportModule(const char *name)
     9.. c:function:: PyObject* PyImport_ImportModule(const char *name)
    1010
    1111   .. index::
     
    1414      single: modules (in module sys)
    1515
    16    This is a simplified interface to :cfunc:`PyImport_ImportModuleEx` below,
     16   This is a simplified interface to :c:func:`PyImport_ImportModuleEx` below,
    1717   leaving the *globals* and *locals* arguments set to *NULL* and *level* set
    1818   to 0.  When the *name*
     
    3535
    3636
    37 .. cfunction:: PyObject* PyImport_ImportModuleNoBlock(const char *name)
    38 
    39    This version of :cfunc:`PyImport_ImportModule` does not block. It's intended
     37.. c:function:: PyObject* PyImport_ImportModuleNoBlock(const char *name)
     38
     39   This version of :c:func:`PyImport_ImportModule` does not block. It's intended
    4040   to be used in C functions that import other modules to execute a function.
    4141   The import may block if another thread holds the import lock. The function
    42    :cfunc:`PyImport_ImportModuleNoBlock` never blocks. It first tries to fetch
    43    the module from sys.modules and falls back to :cfunc:`PyImport_ImportModule`
     42   :c:func:`PyImport_ImportModuleNoBlock` never blocks. It first tries to fetch
     43   the module from sys.modules and falls back to :c:func:`PyImport_ImportModule`
    4444   unless the lock is held, in which case the function will raise an
    4545   :exc:`ImportError`.
     
    4848
    4949
    50 .. cfunction:: PyObject* PyImport_ImportModuleEx(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
     50.. c:function:: PyObject* PyImport_ImportModuleEx(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
    5151
    5252   .. index:: builtin: __import__
     
    6666
    6767   .. versionchanged:: 2.6
    68       The function is an alias for :cfunc:`PyImport_ImportModuleLevel` with
     68      The function is an alias for :c:func:`PyImport_ImportModuleLevel` with
    6969      -1 as level, meaning relative import.
    7070
    7171
    72 .. cfunction:: PyObject* PyImport_ImportModuleLevel(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level)
     72.. c:function:: PyObject* PyImport_ImportModuleLevel(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level)
    7373
    7474   Import a module.  This is best described by referring to the built-in Python
     
    8484
    8585
    86 .. cfunction:: PyObject* PyImport_Import(PyObject *name)
     86.. c:function:: PyObject* PyImport_Import(PyObject *name)
    8787
    8888   .. index::
     
    9999
    100100
    101 .. cfunction:: PyObject* PyImport_ReloadModule(PyObject *m)
     101.. c:function:: PyObject* PyImport_ReloadModule(PyObject *m)
    102102
    103103   .. index:: builtin: reload
     
    109109
    110110
    111 .. cfunction:: PyObject* PyImport_AddModule(const char *name)
     111.. c:function:: PyObject* PyImport_AddModule(const char *name)
    112112
    113113   Return the module object corresponding to a module name.  The *name* argument
     
    119119
    120120      This function does not load or import the module; if the module wasn't already
    121       loaded, you will get an empty module object. Use :cfunc:`PyImport_ImportModule`
     121      loaded, you will get an empty module object. Use :c:func:`PyImport_ImportModule`
    122122      or one of its variants to import a module.  Package structures implied by a
    123123      dotted name for *name* are not created if not already present.
    124124
    125125
    126 .. cfunction:: PyObject* PyImport_ExecCodeModule(char *name, PyObject *co)
     126.. c:function:: PyObject* PyImport_ExecCodeModule(char *name, PyObject *co)
    127127
    128128   .. index:: builtin: compile
     
    134134   module could still be created in error cases.  Starting with Python 2.4, *name*
    135135   is removed from :attr:`sys.modules` in error cases, and even if *name* was already
    136    in :attr:`sys.modules` on entry to :cfunc:`PyImport_ExecCodeModule`.  Leaving
     136   in :attr:`sys.modules` on entry to :c:func:`PyImport_ExecCodeModule`.  Leaving
    137137   incompletely initialized modules in :attr:`sys.modules` is dangerous, as imports of
    138138   such modules have no way to know that the module object is an unknown (and
    139139   probably damaged with respect to the module author's intents) state.
    140140
     141   The module's :attr:`__file__` attribute will be set to the code object's
     142   :c:member:`co_filename`.
     143
    141144   This function will reload the module if it was already imported.  See
    142    :cfunc:`PyImport_ReloadModule` for the intended way to reload a module.
     145   :c:func:`PyImport_ReloadModule` for the intended way to reload a module.
    143146
    144147   If *name* points to a dotted name of the form ``package.module``, any package
     
    149152
    150153
    151 .. cfunction:: long PyImport_GetMagicNumber()
     154.. c:function:: PyObject* PyImport_ExecCodeModuleEx(char *name, PyObject *co, char *pathname)
     155
     156   Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`__file__` attribute of
     157   the module object is set to *pathname* if it is non-``NULL``.
     158
     159
     160.. c:function:: long PyImport_GetMagicNumber()
    152161
    153162   Return the magic number for Python bytecode files (a.k.a. :file:`.pyc` and
     
    156165
    157166
    158 .. cfunction:: PyObject* PyImport_GetModuleDict()
     167.. c:function:: PyObject* PyImport_GetModuleDict()
    159168
    160169   Return the dictionary used for the module administration (a.k.a.
     
    162171
    163172
    164 .. cfunction:: PyObject* PyImport_GetImporter(PyObject *path)
     173.. c:function:: PyObject* PyImport_GetImporter(PyObject *path)
    165174
    166175   Return an importer object for a :data:`sys.path`/:attr:`pkg.__path__` item
     
    175184
    176185
    177 .. cfunction:: void _PyImport_Init()
     186.. c:function:: void _PyImport_Init()
    178187
    179188   Initialize the import mechanism.  For internal use only.
    180189
    181190
    182 .. cfunction:: void PyImport_Cleanup()
     191.. c:function:: void PyImport_Cleanup()
    183192
    184193   Empty the module table.  For internal use only.
    185194
    186195
    187 .. cfunction:: void _PyImport_Fini()
     196.. c:function:: void _PyImport_Fini()
    188197
    189198   Finalize the import mechanism.  For internal use only.
    190199
    191200
    192 .. cfunction:: PyObject* _PyImport_FindExtension(char *, char *)
     201.. c:function:: PyObject* _PyImport_FindExtension(char *, char *)
    193202
    194203   For internal use only.
    195204
    196205
    197 .. cfunction:: PyObject* _PyImport_FixupExtension(char *, char *)
     206.. c:function:: PyObject* _PyImport_FixupExtension(char *, char *)
    198207
    199208   For internal use only.
    200209
    201210
    202 .. cfunction:: int PyImport_ImportFrozenModule(char *name)
     211.. c:function:: int PyImport_ImportFrozenModule(char *name)
    203212
    204213   Load a frozen module named *name*.  Return ``1`` for success, ``0`` if the
    205214   module is not found, and ``-1`` with an exception set if the initialization
    206215   failed.  To access the imported module on a successful load, use
    207    :cfunc:`PyImport_ImportModule`.  (Note the misnomer --- this function would
     216   :c:func:`PyImport_ImportModule`.  (Note the misnomer --- this function would
    208217   reload the module if it was already imported.)
    209218
    210219
    211 .. ctype:: struct _frozen
     220.. c:type:: struct _frozen
    212221
    213222   .. index:: single: freeze utility
     
    225234
    226235
    227 .. cvar:: struct _frozen* PyImport_FrozenModules
    228 
    229    This pointer is initialized to point to an array of :ctype:`struct _frozen`
     236.. c:var:: struct _frozen* PyImport_FrozenModules
     237
     238   This pointer is initialized to point to an array of :c:type:`struct _frozen`
    230239   records, terminated by one whose members are all *NULL* or zero.  When a frozen
    231240   module is imported, it is searched in this table.  Third-party code could play
     
    233242
    234243
    235 .. cfunction:: int PyImport_AppendInittab(char *name, void (*initfunc)(void))
     244.. c:function:: int PyImport_AppendInittab(const char *name, void (*initfunc)(void))
    236245
    237246   Add a single module to the existing table of built-in modules.  This is a
    238    convenience wrapper around :cfunc:`PyImport_ExtendInittab`, returning ``-1`` if
     247   convenience wrapper around :c:func:`PyImport_ExtendInittab`, returning ``-1`` if
    239248   the table could not be extended.  The new module can be imported by the name
    240249   *name*, and uses the function *initfunc* as the initialization function called
    241250   on the first attempted import.  This should be called before
    242    :cfunc:`Py_Initialize`.
    243 
    244 
    245 .. ctype:: struct _inittab
     251   :c:func:`Py_Initialize`.
     252
     253
     254.. c:type:: struct _inittab
    246255
    247256   Structure describing a single entry in the list of built-in modules.  Each of
    248257   these structures gives the name and initialization function for a module built
    249258   into the interpreter.  Programs which embed Python may use an array of these
    250    structures in conjunction with :cfunc:`PyImport_ExtendInittab` to provide
     259   structures in conjunction with :c:func:`PyImport_ExtendInittab` to provide
    251260   additional built-in modules.  The structure is defined in
    252261   :file:`Include/import.h` as::
     
    258267
    259268
    260 .. cfunction:: int PyImport_ExtendInittab(struct _inittab *newtab)
     269.. c:function:: int PyImport_ExtendInittab(struct _inittab *newtab)
    261270
    262271   Add a collection of modules to the table of built-in modules.  The *newtab*
     
    265274   Returns ``0`` on success or ``-1`` if insufficient memory could be allocated to
    266275   extend the internal table.  In the event of failure, no modules are added to the
    267    internal table.  This should be called before :cfunc:`Py_Initialize`.
     276   internal table.  This should be called before :c:func:`Py_Initialize`.
  • python/vendor/current/Doc/c-api/index.rst

    r2 r388  
    44  Python/C API Reference Manual
    55##################################
    6 
    7 :Release: |version|
    8 :Date: |today|
    96
    107This manual documents the API used by C and C++ programmers who want to write
  • python/vendor/current/Doc/c-api/init.rst

    r2 r388  
    99
    1010
    11 .. cfunction:: void Py_Initialize()
     11Initializing and finalizing the interpreter
     12===========================================
     13
     14
     15.. c:function:: void Py_Initialize()
    1216
    1317   .. index::
     
    2327      triple: module; search; path
    2428      single: PySys_SetArgv()
     29      single: PySys_SetArgvEx()
    2530      single: Py_Finalize()
    2631
    2732   Initialize the Python interpreter.  In an application embedding  Python, this
    2833   should be called before using any other Python/C API functions; with the
    29    exception of :cfunc:`Py_SetProgramName`, :cfunc:`PyEval_InitThreads`,
    30    :cfunc:`PyEval_ReleaseLock`, and :cfunc:`PyEval_AcquireLock`. This initializes
     34   exception of :c:func:`Py_SetProgramName`, :c:func:`Py_SetPythonHome`, :c:func:`PyEval_InitThreads`,
     35   :c:func:`PyEval_ReleaseLock`, and :c:func:`PyEval_AcquireLock`. This initializes
    3136   the table of loaded modules (``sys.modules``), and creates the fundamental
    3237   modules :mod:`__builtin__`, :mod:`__main__` and :mod:`sys`.  It also initializes
    3338   the module search path (``sys.path``). It does not set ``sys.argv``; use
    34    :cfunc:`PySys_SetArgv` for that.  This is a no-op when called for a second time
    35    (without calling :cfunc:`Py_Finalize` first).  There is no return value; it is a
     39   :c:func:`PySys_SetArgvEx` for that.  This is a no-op when called for a second time
     40   (without calling :c:func:`Py_Finalize` first).  There is no return value; it is a
    3641   fatal error if the initialization fails.
    3742
    3843
    39 .. cfunction:: void Py_InitializeEx(int initsigs)
    40 
    41    This function works like :cfunc:`Py_Initialize` if *initsigs* is 1. If
     44.. c:function:: void Py_InitializeEx(int initsigs)
     45
     46   This function works like :c:func:`Py_Initialize` if *initsigs* is 1. If
    4247   *initsigs* is 0, it skips initialization registration of signal handlers, which
    4348   might be useful when Python is embedded.
     
    4651
    4752
    48 .. cfunction:: int Py_IsInitialized()
     53.. c:function:: int Py_IsInitialized()
    4954
    5055   Return true (nonzero) when the Python interpreter has been initialized, false
    51    (zero) if not.  After :cfunc:`Py_Finalize` is called, this returns false until
    52    :cfunc:`Py_Initialize` is called again.
    53 
    54 
    55 .. cfunction:: void Py_Finalize()
    56 
    57    Undo all initializations made by :cfunc:`Py_Initialize` and subsequent use of
     56   (zero) if not.  After :c:func:`Py_Finalize` is called, this returns false until
     57   :c:func:`Py_Initialize` is called again.
     58
     59
     60.. c:function:: void Py_Finalize()
     61
     62   Undo all initializations made by :c:func:`Py_Initialize` and subsequent use of
    5863   Python/C API functions, and destroy all sub-interpreters (see
    59    :cfunc:`Py_NewInterpreter` below) that were created and not yet destroyed since
    60    the last call to :cfunc:`Py_Initialize`.  Ideally, this frees all memory
     64   :c:func:`Py_NewInterpreter` below) that were created and not yet destroyed since
     65   the last call to :c:func:`Py_Initialize`.  Ideally, this frees all memory
    6166   allocated by the Python interpreter.  This is a no-op when called for a second
    62    time (without calling :cfunc:`Py_Initialize` again first).  There is no return
     67   time (without calling :c:func:`Py_Initialize` again first).  There is no return
    6368   value; errors during finalization are ignored.
    6469
     
    7984   freed.  Some memory allocated by extension modules may not be freed.  Some
    8085   extensions may not work properly if their initialization routine is called more
    81    than once; this can happen if an application calls :cfunc:`Py_Initialize` and
    82    :cfunc:`Py_Finalize` more than once.
    83 
    84 
    85 .. cfunction:: PyThreadState* Py_NewInterpreter()
     86   than once; this can happen if an application calls :c:func:`Py_Initialize` and
     87   :c:func:`Py_Finalize` more than once.
     88
     89
     90Process-wide parameters
     91=======================
     92
     93
     94.. c:function:: void Py_SetProgramName(char *name)
    8695
    8796   .. index::
    88       module: __builtin__
     97      single: Py_Initialize()
     98      single: main()
     99      single: Py_GetPath()
     100
     101   This function should be called before :c:func:`Py_Initialize` is called for
     102   the first time, if it is called at all.  It tells the interpreter the value
     103   of the ``argv[0]`` argument to the :c:func:`main` function of the program.
     104   This is used by :c:func:`Py_GetPath` and some other functions below to find
     105   the Python run-time libraries relative to the interpreter executable.  The
     106   default value is ``'python'``.  The argument should point to a
     107   zero-terminated character string in static storage whose contents will not
     108   change for the duration of the program's execution.  No code in the Python
     109   interpreter will change the contents of this storage.
     110
     111
     112.. c:function:: char* Py_GetProgramName()
     113
     114   .. index:: single: Py_SetProgramName()
     115
     116   Return the program name set with :c:func:`Py_SetProgramName`, or the default.
     117   The returned string points into static storage; the caller should not modify its
     118   value.
     119
     120
     121.. c:function:: char* Py_GetPrefix()
     122
     123   Return the *prefix* for installed platform-independent files. This is derived
     124   through a number of complicated rules from the program name set with
     125   :c:func:`Py_SetProgramName` and some environment variables; for example, if the
     126   program name is ``'/usr/local/bin/python'``, the prefix is ``'/usr/local'``. The
     127   returned string points into static storage; the caller should not modify its
     128   value.  This corresponds to the :makevar:`prefix` variable in the top-level
     129   :file:`Makefile` and the ``--prefix`` argument to the :program:`configure`
     130   script at build time.  The value is available to Python code as ``sys.prefix``.
     131   It is only useful on Unix.  See also the next function.
     132
     133
     134.. c:function:: char* Py_GetExecPrefix()
     135
     136   Return the *exec-prefix* for installed platform-*dependent* files.  This is
     137   derived through a number of complicated rules from the program name set with
     138   :c:func:`Py_SetProgramName` and some environment variables; for example, if the
     139   program name is ``'/usr/local/bin/python'``, the exec-prefix is
     140   ``'/usr/local'``.  The returned string points into static storage; the caller
     141   should not modify its value.  This corresponds to the :makevar:`exec_prefix`
     142   variable in the top-level :file:`Makefile` and the ``--exec-prefix``
     143   argument to the :program:`configure` script at build  time.  The value is
     144   available to Python code as ``sys.exec_prefix``.  It is only useful on Unix.
     145
     146   Background: The exec-prefix differs from the prefix when platform dependent
     147   files (such as executables and shared libraries) are installed in a different
     148   directory tree.  In a typical installation, platform dependent files may be
     149   installed in the :file:`/usr/local/plat` subtree while platform independent may
     150   be installed in :file:`/usr/local`.
     151
     152   Generally speaking, a platform is a combination of hardware and software
     153   families, e.g.  Sparc machines running the Solaris 2.x operating system are
     154   considered the same platform, but Intel machines running Solaris 2.x are another
     155   platform, and Intel machines running Linux are yet another platform.  Different
     156   major revisions of the same operating system generally also form different
     157   platforms.  Non-Unix operating systems are a different story; the installation
     158   strategies on those systems are so different that the prefix and exec-prefix are
     159   meaningless, and set to the empty string. Note that compiled Python bytecode
     160   files are platform independent (but not independent from the Python version by
     161   which they were compiled!).
     162
     163   System administrators will know how to configure the :program:`mount` or
     164   :program:`automount` programs to share :file:`/usr/local` between platforms
     165   while having :file:`/usr/local/plat` be a different filesystem for each
     166   platform.
     167
     168
     169.. c:function:: char* Py_GetProgramFullPath()
     170
     171   .. index::
     172      single: Py_SetProgramName()
     173      single: executable (in module sys)
     174
     175   Return the full program name of the Python executable; this is  computed as a
     176   side-effect of deriving the default module search path  from the program name
     177   (set by :c:func:`Py_SetProgramName` above). The returned string points into
     178   static storage; the caller should not modify its value.  The value is available
     179   to Python code as ``sys.executable``.
     180
     181
     182.. c:function:: char* Py_GetPath()
     183
     184   .. index::
     185      triple: module; search; path
     186      single: path (in module sys)
     187
     188   Return the default module search path; this is computed from the program name
     189   (set by :c:func:`Py_SetProgramName` above) and some environment variables.
     190   The returned string consists of a series of directory names separated by a
     191   platform dependent delimiter character.  The delimiter character is ``':'``
     192   on Unix and Mac OS X, ``';'`` on Windows.  The returned string points into
     193   static storage; the caller should not modify its value.  The list
     194   :data:`sys.path` is initialized with this value on interpreter startup; it
     195   can be (and usually is) modified later to change the search path for loading
     196   modules.
     197
     198   .. XXX should give the exact rules
     199
     200
     201.. c:function:: const char* Py_GetVersion()
     202
     203   Return the version of this Python interpreter.  This is a string that looks
     204   something like ::
     205
     206      "1.5 (#67, Dec 31 1997, 22:34:28) [GCC 2.7.2.2]"
     207
     208   .. index:: single: version (in module sys)
     209
     210   The first word (up to the first space character) is the current Python version;
     211   the first three characters are the major and minor version separated by a
     212   period.  The returned string points into static storage; the caller should not
     213   modify its value.  The value is available to Python code as ``sys.version``.
     214
     215
     216.. c:function:: const char* Py_GetPlatform()
     217
     218   .. index:: single: platform (in module sys)
     219
     220   Return the platform identifier for the current platform.  On Unix, this is
     221   formed from the "official" name of the operating system, converted to lower
     222   case, followed by the major revision number; e.g., for Solaris 2.x, which is
     223   also known as SunOS 5.x, the value is ``'sunos5'``.  On Mac OS X, it is
     224   ``'darwin'``.  On Windows, it is ``'win'``.  The returned string points into
     225   static storage; the caller should not modify its value.  The value is available
     226   to Python code as ``sys.platform``.
     227
     228
     229.. c:function:: const char* Py_GetCopyright()
     230
     231   Return the official copyright string for the current Python version, for example
     232
     233   ``'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'``
     234
     235   .. index:: single: copyright (in module sys)
     236
     237   The returned string points into static storage; the caller should not modify its
     238   value.  The value is available to Python code as ``sys.copyright``.
     239
     240
     241.. c:function:: const char* Py_GetCompiler()
     242
     243   Return an indication of the compiler used to build the current Python version,
     244   in square brackets, for example::
     245
     246      "[GCC 2.7.2.2]"
     247
     248   .. index:: single: version (in module sys)
     249
     250   The returned string points into static storage; the caller should not modify its
     251   value.  The value is available to Python code as part of the variable
     252   ``sys.version``.
     253
     254
     255.. c:function:: const char* Py_GetBuildInfo()
     256
     257   Return information about the sequence number and build date and time  of the
     258   current Python interpreter instance, for example ::
     259
     260      "#67, Aug  1 1997, 22:34:28"
     261
     262   .. index:: single: version (in module sys)
     263
     264   The returned string points into static storage; the caller should not modify its
     265   value.  The value is available to Python code as part of the variable
     266   ``sys.version``.
     267
     268
     269.. c:function:: void PySys_SetArgvEx(int argc, char **argv, int updatepath)
     270
     271   .. index::
     272      single: main()
     273      single: Py_FatalError()
     274      single: argv (in module sys)
     275
     276   Set :data:`sys.argv` based on *argc* and *argv*.  These parameters are
     277   similar to those passed to the program's :c:func:`main` function with the
     278   difference that the first entry should refer to the script file to be
     279   executed rather than the executable hosting the Python interpreter.  If there
     280   isn't a script that will be run, the first entry in *argv* can be an empty
     281   string.  If this function fails to initialize :data:`sys.argv`, a fatal
     282   condition is signalled using :c:func:`Py_FatalError`.
     283
     284   If *updatepath* is zero, this is all the function does.  If *updatepath*
     285   is non-zero, the function also modifies :data:`sys.path` according to the
     286   following algorithm:
     287
     288   - If the name of an existing script is passed in ``argv[0]``, the absolute
     289     path of the directory where the script is located is prepended to
     290     :data:`sys.path`.
     291   - Otherwise (that is, if *argc* is 0 or ``argv[0]`` doesn't point
     292     to an existing file name), an empty string is prepended to
     293     :data:`sys.path`, which is the same as prepending the current working
     294     directory (``"."``).
     295
     296   .. note::
     297      It is recommended that applications embedding the Python interpreter
     298      for purposes other than executing a single script pass 0 as *updatepath*,
     299      and update :data:`sys.path` themselves if desired.
     300      See `CVE-2008-5983 <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5983>`_.
     301
     302      On versions before 2.6.6, you can achieve the same effect by manually
     303      popping the first :data:`sys.path` element after having called
     304      :c:func:`PySys_SetArgv`, for example using::
     305
     306         PyRun_SimpleString("import sys; sys.path.pop(0)\n");
     307
     308   .. versionadded:: 2.6.6
     309
     310   .. XXX impl. doesn't seem consistent in allowing 0/NULL for the params;
     311      check w/ Guido.
     312
     313
     314.. c:function:: void PySys_SetArgv(int argc, char **argv)
     315
     316   This function works like :c:func:`PySys_SetArgvEx` with *updatepath* set to 1.
     317
     318
     319.. c:function:: void Py_SetPythonHome(char *home)
     320
     321   Set the default "home" directory, that is, the location of the standard
     322   Python libraries.  See :envvar:`PYTHONHOME` for the meaning of the
     323   argument string.
     324
     325   The argument should point to a zero-terminated character string in static
     326   storage whose contents will not change for the duration of the program's
     327   execution.  No code in the Python interpreter will change the contents of
     328   this storage.
     329
     330
     331.. c:function:: char* Py_GetPythonHome()
     332
     333   Return the default "home", that is, the value set by a previous call to
     334   :c:func:`Py_SetPythonHome`, or the value of the :envvar:`PYTHONHOME`
     335   environment variable if it is set.
     336
     337
     338.. _threads:
     339
     340Thread State and the Global Interpreter Lock
     341============================================
     342
     343.. index::
     344   single: GIL
     345   single: global interpreter lock
     346   single: interpreter lock
     347   single: lock, interpreter
     348
     349The Python interpreter is not fully thread-safe.  In order to support
     350multi-threaded Python programs, there's a global lock, called the :term:`global
     351interpreter lock` or :term:`GIL`, that must be held by the current thread before
     352it can safely access Python objects. Without the lock, even the simplest
     353operations could cause problems in a multi-threaded program: for example, when
     354two threads simultaneously increment the reference count of the same object, the
     355reference count could end up being incremented only once instead of twice.
     356
     357.. index:: single: setcheckinterval() (in module sys)
     358
     359Therefore, the rule exists that only the thread that has acquired the
     360:term:`GIL` may operate on Python objects or call Python/C API functions.
     361In order to emulate concurrency of execution, the interpreter regularly
     362tries to switch threads (see :func:`sys.setcheckinterval`).  The lock is also
     363released around potentially blocking I/O operations like reading or writing
     364a file, so that other Python threads can run in the meantime.
     365
     366.. index::
     367   single: PyThreadState
     368   single: PyThreadState
     369
     370The Python interpreter keeps some thread-specific bookkeeping information
     371inside a data structure called :c:type:`PyThreadState`.  There's also one
     372global variable pointing to the current :c:type:`PyThreadState`: it can
     373be retrieved using :c:func:`PyThreadState_Get`.
     374
     375Releasing the GIL from extension code
     376-------------------------------------
     377
     378Most extension code manipulating the :term:`GIL` has the following simple
     379structure::
     380
     381   Save the thread state in a local variable.
     382   Release the global interpreter lock.
     383   ... Do some blocking I/O operation ...
     384   Reacquire the global interpreter lock.
     385   Restore the thread state from the local variable.
     386
     387This is so common that a pair of macros exists to simplify it::
     388
     389   Py_BEGIN_ALLOW_THREADS
     390   ... Do some blocking I/O operation ...
     391   Py_END_ALLOW_THREADS
     392
     393.. index::
     394   single: Py_BEGIN_ALLOW_THREADS
     395   single: Py_END_ALLOW_THREADS
     396
     397The :c:macro:`Py_BEGIN_ALLOW_THREADS` macro opens a new block and declares a
     398hidden local variable; the :c:macro:`Py_END_ALLOW_THREADS` macro closes the
     399block.  These two macros are still available when Python is compiled without
     400thread support (they simply have an empty expansion).
     401
     402When thread support is enabled, the block above expands to the following code::
     403
     404   PyThreadState *_save;
     405
     406   _save = PyEval_SaveThread();
     407   ...Do some blocking I/O operation...
     408   PyEval_RestoreThread(_save);
     409
     410.. index::
     411   single: PyEval_RestoreThread()
     412   single: PyEval_SaveThread()
     413
     414Here is how these functions work: the global interpreter lock is used to protect the pointer to the
     415current thread state.  When releasing the lock and saving the thread state,
     416the current thread state pointer must be retrieved before the lock is released
     417(since another thread could immediately acquire the lock and store its own thread
     418state in the global variable). Conversely, when acquiring the lock and restoring
     419the thread state, the lock must be acquired before storing the thread state
     420pointer.
     421
     422.. note::
     423   Calling system I/O functions is the most common use case for releasing
     424   the GIL, but it can also be useful before calling long-running computations
     425   which don't need access to Python objects, such as compression or
     426   cryptographic functions operating over memory buffers.  For example, the
     427   standard :mod:`zlib` and :mod:`hashlib` modules release the GIL when
     428   compressing or hashing data.
     429
     430
     431.. _gilstate:
     432
     433Non-Python created threads
     434--------------------------
     435
     436When threads are created using the dedicated Python APIs (such as the
     437:mod:`threading` module), a thread state is automatically associated to them
     438and the code showed above is therefore correct.  However, when threads are
     439created from C (for example by a third-party library with its own thread
     440management), they don't hold the GIL, nor is there a thread state structure
     441for them.
     442
     443If you need to call Python code from these threads (often this will be part
     444of a callback API provided by the aforementioned third-party library),
     445you must first register these threads with the interpreter by
     446creating a thread state data structure, then acquiring the GIL, and finally
     447storing their thread state pointer, before you can start using the Python/C
     448API.  When you are done, you should reset the thread state pointer, release
     449the GIL, and finally free the thread state data structure.
     450
     451The :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release` functions do
     452all of the above automatically.  The typical idiom for calling into Python
     453from a C thread is::
     454
     455   PyGILState_STATE gstate;
     456   gstate = PyGILState_Ensure();
     457
     458   /* Perform Python actions here. */
     459   result = CallSomeFunction();
     460   /* evaluate result or handle exception */
     461
     462   /* Release the thread. No Python API allowed beyond this point. */
     463   PyGILState_Release(gstate);
     464
     465Note that the :c:func:`PyGILState_\*` functions assume there is only one global
     466interpreter (created automatically by :c:func:`Py_Initialize`).  Python
     467supports the creation of additional interpreters (using
     468:c:func:`Py_NewInterpreter`), but mixing multiple interpreters and the
     469:c:func:`PyGILState_\*` API is unsupported.
     470
     471Another important thing to note about threads is their behaviour in the face
     472of the C :c:func:`fork` call. On most systems with :c:func:`fork`, after a
     473process forks only the thread that issued the fork will exist. That also
     474means any locks held by other threads will never be released. Python solves
     475this for :func:`os.fork` by acquiring the locks it uses internally before
     476the fork, and releasing them afterwards. In addition, it resets any
     477:ref:`lock-objects` in the child. When extending or embedding Python, there
     478is no way to inform Python of additional (non-Python) locks that need to be
     479acquired before or reset after a fork. OS facilities such as
     480:c:func:`pthread_atfork` would need to be used to accomplish the same thing.
     481Additionally, when extending or embedding Python, calling :c:func:`fork`
     482directly rather than through :func:`os.fork` (and returning to or calling
     483into Python) may result in a deadlock by one of Python's internal locks
     484being held by a thread that is defunct after the fork.
     485:c:func:`PyOS_AfterFork` tries to reset the necessary locks, but is not
     486always able to.
     487
     488
     489High-level API
     490--------------
     491
     492These are the most commonly used types and functions when writing C extension
     493code, or when embedding the Python interpreter:
     494
     495.. c:type:: PyInterpreterState
     496
     497   This data structure represents the state shared by a number of cooperating
     498   threads.  Threads belonging to the same interpreter share their module
     499   administration and a few other internal items. There are no public members in
     500   this structure.
     501
     502   Threads belonging to different interpreters initially share nothing, except
     503   process state like available memory, open file descriptors and such.  The global
     504   interpreter lock is also shared by all threads, regardless of to which
     505   interpreter they belong.
     506
     507
     508.. c:type:: PyThreadState
     509
     510   This data structure represents the state of a single thread.  The only public
     511   data member is :c:type:`PyInterpreterState \*`:attr:`interp`, which points to
     512   this thread's interpreter state.
     513
     514
     515.. c:function:: void PyEval_InitThreads()
     516
     517   .. index::
     518      single: PyEval_ReleaseLock()
     519      single: PyEval_ReleaseThread()
     520      single: PyEval_SaveThread()
     521      single: PyEval_RestoreThread()
     522
     523   Initialize and acquire the global interpreter lock.  It should be called in the
     524   main thread before creating a second thread or engaging in any other thread
     525   operations such as :c:func:`PyEval_ReleaseLock` or
     526   ``PyEval_ReleaseThread(tstate)``. It is not needed before calling
     527   :c:func:`PyEval_SaveThread` or :c:func:`PyEval_RestoreThread`.
     528
     529   .. index:: single: Py_Initialize()
     530
     531   This is a no-op when called for a second time.  It is safe to call this function
     532   before calling :c:func:`Py_Initialize`.
     533
     534   .. index:: module: thread
     535
     536   .. note::
     537      When only the main thread exists, no GIL operations are needed. This is a
     538      common situation (most Python programs do not use threads), and the lock
     539      operations slow the interpreter down a bit. Therefore, the lock is not
     540      created initially.  This situation is equivalent to having acquired the lock:
     541      when there is only a single thread, all object accesses are safe.  Therefore,
     542      when this function initializes the global interpreter lock, it also acquires
     543      it.  Before the Python :mod:`_thread` module creates a new thread, knowing
     544      that either it has the lock or the lock hasn't been created yet, it calls
     545      :c:func:`PyEval_InitThreads`.  When this call returns, it is guaranteed that
     546      the lock has been created and that the calling thread has acquired it.
     547
     548      It is **not** safe to call this function when it is unknown which thread (if
     549      any) currently has the global interpreter lock.
     550
     551      This function is not available when thread support is disabled at compile time.
     552
     553
     554.. c:function:: int PyEval_ThreadsInitialized()
     555
     556   Returns a non-zero value if :c:func:`PyEval_InitThreads` has been called.  This
     557   function can be called without holding the GIL, and therefore can be used to
     558   avoid calls to the locking API when running single-threaded.  This function is
     559   not available when thread support is disabled at compile time.
     560
     561   .. versionadded:: 2.4
     562
     563
     564.. c:function:: PyThreadState* PyEval_SaveThread()
     565
     566   Release the global interpreter lock (if it has been created and thread
     567   support is enabled) and reset the thread state to *NULL*, returning the
     568   previous thread state (which is not *NULL*).  If the lock has been created,
     569   the current thread must have acquired it.  (This function is available even
     570   when thread support is disabled at compile time.)
     571
     572
     573.. c:function:: void PyEval_RestoreThread(PyThreadState *tstate)
     574
     575   Acquire the global interpreter lock (if it has been created and thread
     576   support is enabled) and set the thread state to *tstate*, which must not be
     577   *NULL*.  If the lock has been created, the current thread must not have
     578   acquired it, otherwise deadlock ensues.  (This function is available even
     579   when thread support is disabled at compile time.)
     580
     581
     582.. c:function:: PyThreadState* PyThreadState_Get()
     583
     584   Return the current thread state.  The global interpreter lock must be held.
     585   When the current thread state is *NULL*, this issues a fatal error (so that
     586   the caller needn't check for *NULL*).
     587
     588
     589.. c:function:: PyThreadState* PyThreadState_Swap(PyThreadState *tstate)
     590
     591   Swap the current thread state with the thread state given by the argument
     592   *tstate*, which may be *NULL*.  The global interpreter lock must be held
     593   and is not released.
     594
     595
     596.. c:function:: void PyEval_ReInitThreads()
     597
     598   This function is called from :c:func:`PyOS_AfterFork` to ensure that newly
     599   created child processes don't hold locks referring to threads which
     600   are not running in the child process.
     601
     602
     603The following functions use thread-local storage, and are not compatible
     604with sub-interpreters:
     605
     606.. c:function:: PyGILState_STATE PyGILState_Ensure()
     607
     608   Ensure that the current thread is ready to call the Python C API regardless
     609   of the current state of Python, or of the global interpreter lock. This may
     610   be called as many times as desired by a thread as long as each call is
     611   matched with a call to :c:func:`PyGILState_Release`. In general, other
     612   thread-related APIs may be used between :c:func:`PyGILState_Ensure` and
     613   :c:func:`PyGILState_Release` calls as long as the thread state is restored to
     614   its previous state before the Release().  For example, normal usage of the
     615   :c:macro:`Py_BEGIN_ALLOW_THREADS` and :c:macro:`Py_END_ALLOW_THREADS` macros is
     616   acceptable.
     617
     618   The return value is an opaque "handle" to the thread state when
     619   :c:func:`PyGILState_Ensure` was called, and must be passed to
     620   :c:func:`PyGILState_Release` to ensure Python is left in the same state. Even
     621   though recursive calls are allowed, these handles *cannot* be shared - each
     622   unique call to :c:func:`PyGILState_Ensure` must save the handle for its call
     623   to :c:func:`PyGILState_Release`.
     624
     625   When the function returns, the current thread will hold the GIL and be able
     626   to call arbitrary Python code.  Failure is a fatal error.
     627
     628   .. versionadded:: 2.3
     629
     630
     631.. c:function:: void PyGILState_Release(PyGILState_STATE)
     632
     633   Release any resources previously acquired.  After this call, Python's state will
     634   be the same as it was prior to the corresponding :c:func:`PyGILState_Ensure` call
     635   (but generally this state will be unknown to the caller, hence the use of the
     636   GILState API).
     637
     638   Every call to :c:func:`PyGILState_Ensure` must be matched by a call to
     639   :c:func:`PyGILState_Release` on the same thread.
     640
     641   .. versionadded:: 2.3
     642
     643
     644.. c:function:: PyThreadState PyGILState_GetThisThreadState()
     645
     646   Get the current thread state for this thread.  May return ``NULL`` if no
     647   GILState API has been used on the current thread.  Note that the main thread
     648   always has such a thread-state, even if no auto-thread-state call has been
     649   made on the main thread.  This is mainly a helper/diagnostic function.
     650
     651   .. versionadded:: 2.3
     652
     653
     654The following macros are normally used without a trailing semicolon; look for
     655example usage in the Python source distribution.
     656
     657
     658.. c:macro:: Py_BEGIN_ALLOW_THREADS
     659
     660   This macro expands to ``{ PyThreadState *_save; _save = PyEval_SaveThread();``.
     661   Note that it contains an opening brace; it must be matched with a following
     662   :c:macro:`Py_END_ALLOW_THREADS` macro.  See above for further discussion of this
     663   macro.  It is a no-op when thread support is disabled at compile time.
     664
     665
     666.. c:macro:: Py_END_ALLOW_THREADS
     667
     668   This macro expands to ``PyEval_RestoreThread(_save); }``. Note that it contains
     669   a closing brace; it must be matched with an earlier
     670   :c:macro:`Py_BEGIN_ALLOW_THREADS` macro.  See above for further discussion of
     671   this macro.  It is a no-op when thread support is disabled at compile time.
     672
     673
     674.. c:macro:: Py_BLOCK_THREADS
     675
     676   This macro expands to ``PyEval_RestoreThread(_save);``: it is equivalent to
     677   :c:macro:`Py_END_ALLOW_THREADS` without the closing brace.  It is a no-op when
     678   thread support is disabled at compile time.
     679
     680
     681.. c:macro:: Py_UNBLOCK_THREADS
     682
     683   This macro expands to ``_save = PyEval_SaveThread();``: it is equivalent to
     684   :c:macro:`Py_BEGIN_ALLOW_THREADS` without the opening brace and variable
     685   declaration.  It is a no-op when thread support is disabled at compile time.
     686
     687
     688Low-level API
     689-------------
     690
     691All of the following functions are only available when thread support is enabled
     692at compile time, and must be called only when the global interpreter lock has
     693been created.
     694
     695
     696.. c:function:: PyInterpreterState* PyInterpreterState_New()
     697
     698   Create a new interpreter state object.  The global interpreter lock need not
     699   be held, but may be held if it is necessary to serialize calls to this
     700   function.
     701
     702
     703.. c:function:: void PyInterpreterState_Clear(PyInterpreterState *interp)
     704
     705   Reset all information in an interpreter state object.  The global interpreter
     706   lock must be held.
     707
     708
     709.. c:function:: void PyInterpreterState_Delete(PyInterpreterState *interp)
     710
     711   Destroy an interpreter state object.  The global interpreter lock need not be
     712   held.  The interpreter state must have been reset with a previous call to
     713   :c:func:`PyInterpreterState_Clear`.
     714
     715
     716.. c:function:: PyThreadState* PyThreadState_New(PyInterpreterState *interp)
     717
     718   Create a new thread state object belonging to the given interpreter object.
     719   The global interpreter lock need not be held, but may be held if it is
     720   necessary to serialize calls to this function.
     721
     722
     723.. c:function:: void PyThreadState_Clear(PyThreadState *tstate)
     724
     725   Reset all information in a thread state object.  The global interpreter lock
     726   must be held.
     727
     728
     729.. c:function:: void PyThreadState_Delete(PyThreadState *tstate)
     730
     731   Destroy a thread state object.  The global interpreter lock need not be held.
     732   The thread state must have been reset with a previous call to
     733   :c:func:`PyThreadState_Clear`.
     734
     735
     736.. c:function:: PyObject* PyThreadState_GetDict()
     737
     738   Return a dictionary in which extensions can store thread-specific state
     739   information.  Each extension should use a unique key to use to store state in
     740   the dictionary.  It is okay to call this function when no current thread state
     741   is available. If this function returns *NULL*, no exception has been raised and
     742   the caller should assume no current thread state is available.
     743
     744   .. versionchanged:: 2.3
     745      Previously this could only be called when a current thread is active, and *NULL*
     746      meant that an exception was raised.
     747
     748
     749.. c:function:: int PyThreadState_SetAsyncExc(long id, PyObject *exc)
     750
     751   Asynchronously raise an exception in a thread. The *id* argument is the thread
     752   id of the target thread; *exc* is the exception object to be raised. This
     753   function does not steal any references to *exc*. To prevent naive misuse, you
     754   must write your own C extension to call this.  Must be called with the GIL held.
     755   Returns the number of thread states modified; this is normally one, but will be
     756   zero if the thread id isn't found.  If *exc* is :const:`NULL`, the pending
     757   exception (if any) for the thread is cleared. This raises no exceptions.
     758
     759   .. versionadded:: 2.3
     760
     761
     762.. c:function:: void PyEval_AcquireThread(PyThreadState *tstate)
     763
     764   Acquire the global interpreter lock and set the current thread state to
     765   *tstate*, which should not be *NULL*.  The lock must have been created earlier.
     766   If this thread already has the lock, deadlock ensues.
     767
     768   :c:func:`PyEval_RestoreThread` is a higher-level function which is always
     769   available (even when thread support isn't enabled or when threads have
     770   not been initialized).
     771
     772
     773.. c:function:: void PyEval_ReleaseThread(PyThreadState *tstate)
     774
     775   Reset the current thread state to *NULL* and release the global interpreter
     776   lock.  The lock must have been created earlier and must be held by the current
     777   thread.  The *tstate* argument, which must not be *NULL*, is only used to check
     778   that it represents the current thread state --- if it isn't, a fatal error is
     779   reported.
     780
     781   :c:func:`PyEval_SaveThread` is a higher-level function which is always
     782   available (even when thread support isn't enabled or when threads have
     783   not been initialized).
     784
     785
     786.. c:function:: void PyEval_AcquireLock()
     787
     788   Acquire the global interpreter lock.  The lock must have been created earlier.
     789   If this thread already has the lock, a deadlock ensues.
     790
     791   .. warning::
     792      This function does not change the current thread state.  Please use
     793      :c:func:`PyEval_RestoreThread` or :c:func:`PyEval_AcquireThread`
     794      instead.
     795
     796
     797.. c:function:: void PyEval_ReleaseLock()
     798
     799   Release the global interpreter lock.  The lock must have been created earlier.
     800
     801   .. warning::
     802      This function does not change the current thread state.  Please use
     803      :c:func:`PyEval_SaveThread` or :c:func:`PyEval_ReleaseThread`
     804      instead.
     805
     806
     807Sub-interpreter support
     808=======================
     809
     810While in most uses, you will only embed a single Python interpreter, there
     811are cases where you need to create several independent interpreters in the
     812same process and perhaps even in the same thread.  Sub-interpreters allow
     813you to do that.  You can switch between sub-interpreters using the
     814:c:func:`PyThreadState_Swap` function.  You can create and destroy them
     815using the following functions:
     816
     817
     818.. c:function:: PyThreadState* Py_NewInterpreter()
     819
     820   .. index::
     821      module: builtins
    89822      module: __main__
    90823      module: sys
     
    96829   for the execution of Python code.  In particular, the new interpreter has
    97830   separate, independent versions of all imported modules, including the
    98    fundamental modules :mod:`__builtin__`, :mod:`__main__` and :mod:`sys`.  The
     831   fundamental modules :mod:`builtins`, :mod:`__main__` and :mod:`sys`.  The
    99832   table of loaded modules (``sys.modules``) and the module search path
    100833   (``sys.path``) are also separate.  The new environment has no ``sys.argv``
    101834   variable.  It has new standard I/O stream file objects ``sys.stdin``,
    102835   ``sys.stdout`` and ``sys.stderr`` (however these refer to the same underlying
    103    :ctype:`FILE` structures in the C library).
     836   file descriptors).
    104837
    105838   The return value points to the first thread state created in the new
     
    125858   not called.  Note that this is different from what happens when an extension is
    126859   imported after the interpreter has been completely re-initialized by calling
    127    :cfunc:`Py_Finalize` and :cfunc:`Py_Initialize`; in that case, the extension's
     860   :c:func:`Py_Finalize` and :c:func:`Py_Initialize`; in that case, the extension's
    128861   ``initmodule`` function *is* called again.
    129862
    130863   .. index:: single: close() (in module os)
    131864
    132    **Bugs and caveats:** Because sub-interpreters (and the main interpreter) are
    133    part of the same process, the insulation between them isn't perfect --- for
    134    example, using low-level file operations like  :func:`os.close` they can
    135    (accidentally or maliciously) affect each other's open files.  Because of the
    136    way extensions are shared between (sub-)interpreters, some extensions may not
    137    work properly; this is especially likely when the extension makes use of
    138    (static) global variables, or when the extension manipulates its module's
    139    dictionary after its initialization.  It is possible to insert objects created
    140    in one sub-interpreter into a namespace of another sub-interpreter; this should
    141    be done with great care to avoid sharing user-defined functions, methods,
    142    instances or classes between sub-interpreters, since import operations executed
    143    by such objects may affect the wrong (sub-)interpreter's dictionary of loaded
    144    modules.  (XXX This is a hard-to-fix bug that will be addressed in a future
    145    release.)
    146 
    147    Also note that the use of this functionality is incompatible with extension
    148    modules such as PyObjC and ctypes that use the :cfunc:`PyGILState_\*` APIs (and
    149    this is inherent in the way the :cfunc:`PyGILState_\*` functions work).  Simple
    150    things may work, but confusing behavior will always be near.
    151 
    152 
    153 .. cfunction:: void Py_EndInterpreter(PyThreadState *tstate)
     865
     866.. c:function:: void Py_EndInterpreter(PyThreadState *tstate)
    154867
    155868   .. index:: single: Py_Finalize()
     
    160873   thread states associated with this interpreter are destroyed.  (The global
    161874   interpreter lock must be held before calling this function and is still held
    162    when it returns.)  :cfunc:`Py_Finalize` will destroy all sub-interpreters that
     875   when it returns.)  :c:func:`Py_Finalize` will destroy all sub-interpreters that
    163876   haven't been explicitly destroyed at that point.
    164877
    165878
    166 .. cfunction:: void Py_SetProgramName(char *name)
    167 
    168    .. index::
    169       single: Py_Initialize()
    170       single: main()
    171       single: Py_GetPath()
    172 
    173    This function should be called before :cfunc:`Py_Initialize` is called for
    174    the first time, if it is called at all.  It tells the interpreter the value
    175    of the ``argv[0]`` argument to the :cfunc:`main` function of the program.
    176    This is used by :cfunc:`Py_GetPath` and some other functions below to find
    177    the Python run-time libraries relative to the interpreter executable.  The
    178    default value is ``'python'``.  The argument should point to a
    179    zero-terminated character string in static storage whose contents will not
    180    change for the duration of the program's execution.  No code in the Python
    181    interpreter will change the contents of this storage.
    182 
    183 
    184 .. cfunction:: char* Py_GetProgramName()
    185 
    186    .. index:: single: Py_SetProgramName()
    187 
    188    Return the program name set with :cfunc:`Py_SetProgramName`, or the default.
    189    The returned string points into static storage; the caller should not modify its
    190    value.
    191 
    192 
    193 .. cfunction:: char* Py_GetPrefix()
    194 
    195    Return the *prefix* for installed platform-independent files. This is derived
    196    through a number of complicated rules from the program name set with
    197    :cfunc:`Py_SetProgramName` and some environment variables; for example, if the
    198    program name is ``'/usr/local/bin/python'``, the prefix is ``'/usr/local'``. The
    199    returned string points into static storage; the caller should not modify its
    200    value.  This corresponds to the :makevar:`prefix` variable in the top-level
    201    :file:`Makefile` and the :option:`--prefix` argument to the :program:`configure`
    202    script at build time.  The value is available to Python code as ``sys.prefix``.
    203    It is only useful on Unix.  See also the next function.
    204 
    205 
    206 .. cfunction:: char* Py_GetExecPrefix()
    207 
    208    Return the *exec-prefix* for installed platform-*dependent* files.  This is
    209    derived through a number of complicated rules from the program name set with
    210    :cfunc:`Py_SetProgramName` and some environment variables; for example, if the
    211    program name is ``'/usr/local/bin/python'``, the exec-prefix is
    212    ``'/usr/local'``.  The returned string points into static storage; the caller
    213    should not modify its value.  This corresponds to the :makevar:`exec_prefix`
    214    variable in the top-level :file:`Makefile` and the :option:`--exec-prefix`
    215    argument to the :program:`configure` script at build  time.  The value is
    216    available to Python code as ``sys.exec_prefix``.  It is only useful on Unix.
    217 
    218    Background: The exec-prefix differs from the prefix when platform dependent
    219    files (such as executables and shared libraries) are installed in a different
    220    directory tree.  In a typical installation, platform dependent files may be
    221    installed in the :file:`/usr/local/plat` subtree while platform independent may
    222    be installed in :file:`/usr/local`.
    223 
    224    Generally speaking, a platform is a combination of hardware and software
    225    families, e.g.  Sparc machines running the Solaris 2.x operating system are
    226    considered the same platform, but Intel machines running Solaris 2.x are another
    227    platform, and Intel machines running Linux are yet another platform.  Different
    228    major revisions of the same operating system generally also form different
    229    platforms.  Non-Unix operating systems are a different story; the installation
    230    strategies on those systems are so different that the prefix and exec-prefix are
    231    meaningless, and set to the empty string. Note that compiled Python bytecode
    232    files are platform independent (but not independent from the Python version by
    233    which they were compiled!).
    234 
    235    System administrators will know how to configure the :program:`mount` or
    236    :program:`automount` programs to share :file:`/usr/local` between platforms
    237    while having :file:`/usr/local/plat` be a different filesystem for each
    238    platform.
    239 
    240 
    241 .. cfunction:: char* Py_GetProgramFullPath()
    242 
    243    .. index::
    244       single: Py_SetProgramName()
    245       single: executable (in module sys)
    246 
    247    Return the full program name of the Python executable; this is  computed as a
    248    side-effect of deriving the default module search path  from the program name
    249    (set by :cfunc:`Py_SetProgramName` above). The returned string points into
    250    static storage; the caller should not modify its value.  The value is available
    251    to Python code as ``sys.executable``.
    252 
    253 
    254 .. cfunction:: char* Py_GetPath()
    255 
    256    .. index::
    257       triple: module; search; path
    258       single: path (in module sys)
    259 
    260    Return the default module search path; this is computed from the  program name
    261    (set by :cfunc:`Py_SetProgramName` above) and some environment variables.  The
    262    returned string consists of a series of directory names separated by a platform
    263    dependent delimiter character.  The delimiter character is ``':'`` on Unix and
    264    Mac OS X, ``';'`` on Windows.  The returned string points into static storage;
    265    the caller should not modify its value.  The value is available to Python code
    266    as the list ``sys.path``, which may be modified to change the future search path
    267    for loaded modules.
    268 
    269    .. XXX should give the exact rules
    270 
    271 
    272 .. cfunction:: const char* Py_GetVersion()
    273 
    274    Return the version of this Python interpreter.  This is a string that looks
    275    something like ::
    276 
    277       "1.5 (#67, Dec 31 1997, 22:34:28) [GCC 2.7.2.2]"
    278 
    279    .. index:: single: version (in module sys)
    280 
    281    The first word (up to the first space character) is the current Python version;
    282    the first three characters are the major and minor version separated by a
    283    period.  The returned string points into static storage; the caller should not
    284    modify its value.  The value is available to Python code as ``sys.version``.
    285 
    286 
    287 .. cfunction:: const char* Py_GetBuildNumber()
    288 
    289    Return a string representing the Subversion revision that this Python executable
    290    was built from.  This number is a string because it may contain a trailing 'M'
    291    if Python was built from a mixed revision source tree.
    292 
    293    .. versionadded:: 2.5
    294 
    295 
    296 .. cfunction:: const char* Py_GetPlatform()
    297 
    298    .. index:: single: platform (in module sys)
    299 
    300    Return the platform identifier for the current platform.  On Unix, this is
    301    formed from the "official" name of the operating system, converted to lower
    302    case, followed by the major revision number; e.g., for Solaris 2.x, which is
    303    also known as SunOS 5.x, the value is ``'sunos5'``.  On Mac OS X, it is
    304    ``'darwin'``.  On Windows, it is ``'win'``.  The returned string points into
    305    static storage; the caller should not modify its value.  The value is available
    306    to Python code as ``sys.platform``.
    307 
    308 
    309 .. cfunction:: const char* Py_GetCopyright()
    310 
    311    Return the official copyright string for the current Python version, for example
    312 
    313    ``'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'``
    314 
    315    .. index:: single: copyright (in module sys)
    316 
    317    The returned string points into static storage; the caller should not modify its
    318    value.  The value is available to Python code as ``sys.copyright``.
    319 
    320 
    321 .. cfunction:: const char* Py_GetCompiler()
    322 
    323    Return an indication of the compiler used to build the current Python version,
    324    in square brackets, for example::
    325 
    326       "[GCC 2.7.2.2]"
    327 
    328    .. index:: single: version (in module sys)
    329 
    330    The returned string points into static storage; the caller should not modify its
    331    value.  The value is available to Python code as part of the variable
    332    ``sys.version``.
    333 
    334 
    335 .. cfunction:: const char* Py_GetBuildInfo()
    336 
    337    Return information about the sequence number and build date and time  of the
    338    current Python interpreter instance, for example ::
    339 
    340       "#67, Aug  1 1997, 22:34:28"
    341 
    342    .. index:: single: version (in module sys)
    343 
    344    The returned string points into static storage; the caller should not modify its
    345    value.  The value is available to Python code as part of the variable
    346    ``sys.version``.
    347 
    348 
    349 .. cfunction:: void PySys_SetArgv(int argc, char **argv)
    350 
    351    .. index::
    352       single: main()
    353       single: Py_FatalError()
    354       single: argv (in module sys)
    355 
    356    Set :data:`sys.argv` based on *argc* and *argv*.  These parameters are
    357    similar to those passed to the program's :cfunc:`main` function with the
    358    difference that the first entry should refer to the script file to be
    359    executed rather than the executable hosting the Python interpreter.  If there
    360    isn't a script that will be run, the first entry in *argv* can be an empty
    361    string.  If this function fails to initialize :data:`sys.argv`, a fatal
    362    condition is signalled using :cfunc:`Py_FatalError`.
    363 
    364    This function also prepends the executed script's path to :data:`sys.path`.
    365    If no script is executed (in the case of calling ``python -c`` or just the
    366    interactive interpreter), the empty string is used instead.
    367 
    368    .. XXX impl. doesn't seem consistent in allowing 0/NULL for the params;
    369       check w/ Guido.
    370 
    371 
    372 .. cfunction:: void Py_SetPythonHome(char *home)
    373 
    374    Set the default "home" directory, that is, the location of the standard
    375    Python libraries.  The libraries are searched in
    376    :file:`{home}/lib/python{version}` and :file:`{home}/lib/python{version}`.
    377    The argument should point to a zero-terminated character string in static
    378    storage whose contents will not change for the duration of the program's
    379    execution.  No code in the Python interpreter will change the contents of
    380    this storage.
    381 
    382 
    383 .. cfunction:: char* Py_GetPythonHome()
    384 
    385    Return the default "home", that is, the value set by a previous call to
    386    :cfunc:`Py_SetPythonHome`, or the value of the :envvar:`PYTHONHOME`
    387    environment variable if it is set.
    388 
    389 
    390 .. _threads:
    391 
    392 Thread State and the Global Interpreter Lock
    393 ============================================
    394 
    395 .. index::
    396    single: global interpreter lock
    397    single: interpreter lock
    398    single: lock, interpreter
    399 
    400 The Python interpreter is not fully thread safe.  In order to support
    401 multi-threaded Python programs, there's a global lock, called the :dfn:`global
    402 interpreter lock` or :dfn:`GIL`, that must be held by the current thread before
    403 it can safely access Python objects. Without the lock, even the simplest
    404 operations could cause problems in a multi-threaded program: for example, when
    405 two threads simultaneously increment the reference count of the same object, the
    406 reference count could end up being incremented only once instead of twice.
    407 
    408 .. index:: single: setcheckinterval() (in module sys)
    409 
    410 Therefore, the rule exists that only the thread that has acquired the global
    411 interpreter lock may operate on Python objects or call Python/C API functions.
    412 In order to support multi-threaded Python programs, the interpreter regularly
    413 releases and reacquires the lock --- by default, every 100 bytecode instructions
    414 (this can be changed with  :func:`sys.setcheckinterval`).  The lock is also
    415 released and reacquired around potentially blocking I/O operations like reading
    416 or writing a file, so that other threads can run while the thread that requests
    417 the I/O is waiting for the I/O operation to complete.
    418 
    419 .. index::
    420    single: PyThreadState
    421    single: PyThreadState
    422 
    423 The Python interpreter needs to keep some bookkeeping information separate per
    424 thread --- for this it uses a data structure called :ctype:`PyThreadState`.
    425 There's one global variable, however: the pointer to the current
    426 :ctype:`PyThreadState` structure.  Before the addition of :dfn:`thread-local
    427 storage` (:dfn:`TLS`) the current thread state had to be manipulated
    428 explicitly.
    429 
    430 This is easy enough in most cases.  Most code manipulating the global
    431 interpreter lock has the following simple structure::
    432 
    433    Save the thread state in a local variable.
    434    Release the global interpreter lock.
    435    ...Do some blocking I/O operation...
    436    Reacquire the global interpreter lock.
    437    Restore the thread state from the local variable.
    438 
    439 This is so common that a pair of macros exists to simplify it::
    440 
    441    Py_BEGIN_ALLOW_THREADS
    442    ...Do some blocking I/O operation...
    443    Py_END_ALLOW_THREADS
    444 
    445 .. index::
    446    single: Py_BEGIN_ALLOW_THREADS
    447    single: Py_END_ALLOW_THREADS
    448 
    449 The :cmacro:`Py_BEGIN_ALLOW_THREADS` macro opens a new block and declares a
    450 hidden local variable; the :cmacro:`Py_END_ALLOW_THREADS` macro closes the
    451 block.  Another advantage of using these two macros is that when Python is
    452 compiled without thread support, they are defined empty, thus saving the thread
    453 state and GIL manipulations.
    454 
    455 When thread support is enabled, the block above expands to the following code::
    456 
    457    PyThreadState *_save;
    458 
    459    _save = PyEval_SaveThread();
    460    ...Do some blocking I/O operation...
    461    PyEval_RestoreThread(_save);
    462 
    463 Using even lower level primitives, we can get roughly the same effect as
    464 follows::
    465 
    466    PyThreadState *_save;
    467 
    468    _save = PyThreadState_Swap(NULL);
    469    PyEval_ReleaseLock();
    470    ...Do some blocking I/O operation...
    471    PyEval_AcquireLock();
    472    PyThreadState_Swap(_save);
    473 
    474 .. index::
    475    single: PyEval_RestoreThread()
    476    single: errno
    477    single: PyEval_SaveThread()
    478    single: PyEval_ReleaseLock()
    479    single: PyEval_AcquireLock()
    480 
    481 There are some subtle differences; in particular, :cfunc:`PyEval_RestoreThread`
    482 saves and restores the value of the  global variable :cdata:`errno`, since the
    483 lock manipulation does not guarantee that :cdata:`errno` is left alone.  Also,
    484 when thread support is disabled, :cfunc:`PyEval_SaveThread` and
    485 :cfunc:`PyEval_RestoreThread` don't manipulate the GIL; in this case,
    486 :cfunc:`PyEval_ReleaseLock` and :cfunc:`PyEval_AcquireLock` are not available.
    487 This is done so that dynamically loaded extensions compiled with thread support
    488 enabled can be loaded by an interpreter that was compiled with disabled thread
    489 support.
    490 
    491 The global interpreter lock is used to protect the pointer to the current thread
    492 state.  When releasing the lock and saving the thread state, the current thread
    493 state pointer must be retrieved before the lock is released (since another
    494 thread could immediately acquire the lock and store its own thread state in the
    495 global variable). Conversely, when acquiring the lock and restoring the thread
    496 state, the lock must be acquired before storing the thread state pointer.
    497 
    498 It is important to note that when threads are created from C, they don't have
    499 the global interpreter lock, nor is there a thread state data structure for
    500 them.  Such threads must bootstrap themselves into existence, by first
    501 creating a thread state data structure, then acquiring the lock, and finally
    502 storing their thread state pointer, before they can start using the Python/C
    503 API.  When they are done, they should reset the thread state pointer, release
    504 the lock, and finally free their thread state data structure.
    505 
    506 Beginning with version 2.3, threads can now take advantage of the
    507 :cfunc:`PyGILState_\*` functions to do all of the above automatically.  The
    508 typical idiom for calling into Python from a C thread is now::
    509 
    510    PyGILState_STATE gstate;
    511    gstate = PyGILState_Ensure();
    512 
    513    /* Perform Python actions here.  */
    514    result = CallSomeFunction();
    515    /* evaluate result */
    516 
    517    /* Release the thread. No Python API allowed beyond this point. */
    518    PyGILState_Release(gstate);
    519 
    520 Note that the :cfunc:`PyGILState_\*` functions assume there is only one global
    521 interpreter (created automatically by :cfunc:`Py_Initialize`).  Python still
    522 supports the creation of additional interpreters (using
    523 :cfunc:`Py_NewInterpreter`), but mixing multiple interpreters and the
    524 :cfunc:`PyGILState_\*` API is unsupported.
    525 
    526 Another important thing to note about threads is their behaviour in the face
    527 of the C :cfunc:`fork` call. On most systems with :cfunc:`fork`, after a
    528 process forks only the thread that issued the fork will exist. That also
    529 means any locks held by other threads will never be released. Python solves
    530 this for :func:`os.fork` by acquiring the locks it uses internally before
    531 the fork, and releasing them afterwards. In addition, it resets any
    532 :ref:`lock-objects` in the child. When extending or embedding Python, there
    533 is no way to inform Python of additional (non-Python) locks that need to be
    534 acquired before or reset after a fork. OS facilities such as
    535 :cfunc:`posix_atfork` would need to be used to accomplish the same thing.
    536 Additionally, when extending or embedding Python, calling :cfunc:`fork`
    537 directly rather than through :func:`os.fork` (and returning to or calling
    538 into Python) may result in a deadlock by one of Python's internal locks
    539 being held by a thread that is defunct after the fork.
    540 :cfunc:`PyOS_AfterFork` tries to reset the necessary locks, but is not
    541 always able to.
    542 
    543 .. ctype:: PyInterpreterState
    544 
    545    This data structure represents the state shared by a number of cooperating
    546    threads.  Threads belonging to the same interpreter share their module
    547    administration and a few other internal items. There are no public members in
    548    this structure.
    549 
    550    Threads belonging to different interpreters initially share nothing, except
    551    process state like available memory, open file descriptors and such.  The global
    552    interpreter lock is also shared by all threads, regardless of to which
    553    interpreter they belong.
    554 
    555 
    556 .. ctype:: PyThreadState
    557 
    558    This data structure represents the state of a single thread.  The only public
    559    data member is :ctype:`PyInterpreterState \*`:attr:`interp`, which points to
    560    this thread's interpreter state.
    561 
    562 
    563 .. cfunction:: void PyEval_InitThreads()
    564 
    565    .. index::
    566       single: PyEval_ReleaseLock()
    567       single: PyEval_ReleaseThread()
    568       single: PyEval_SaveThread()
    569       single: PyEval_RestoreThread()
    570 
    571    Initialize and acquire the global interpreter lock.  It should be called in the
    572    main thread before creating a second thread or engaging in any other thread
    573    operations such as :cfunc:`PyEval_ReleaseLock` or
    574    ``PyEval_ReleaseThread(tstate)``. It is not needed before calling
    575    :cfunc:`PyEval_SaveThread` or :cfunc:`PyEval_RestoreThread`.
    576 
    577    .. index:: single: Py_Initialize()
    578 
    579    This is a no-op when called for a second time.  It is safe to call this function
    580    before calling :cfunc:`Py_Initialize`.
    581 
    582    .. index:: module: thread
    583 
    584    When only the main thread exists, no GIL operations are needed. This is a
    585    common situation (most Python programs do not use threads), and the lock
    586    operations slow the interpreter down a bit. Therefore, the lock is not
    587    created initially.  This situation is equivalent to having acquired the lock:
    588    when there is only a single thread, all object accesses are safe.  Therefore,
    589    when this function initializes the global interpreter lock, it also acquires
    590    it.  Before the Python :mod:`thread` module creates a new thread, knowing
    591    that either it has the lock or the lock hasn't been created yet, it calls
    592    :cfunc:`PyEval_InitThreads`.  When this call returns, it is guaranteed that
    593    the lock has been created and that the calling thread has acquired it.
    594 
    595    It is **not** safe to call this function when it is unknown which thread (if
    596    any) currently has the global interpreter lock.
    597 
    598    This function is not available when thread support is disabled at compile time.
    599 
    600 
    601 .. cfunction:: int PyEval_ThreadsInitialized()
    602 
    603    Returns a non-zero value if :cfunc:`PyEval_InitThreads` has been called.  This
    604    function can be called without holding the GIL, and therefore can be used to
    605    avoid calls to the locking API when running single-threaded.  This function is
    606    not available when thread support is disabled at compile time.
    607 
    608    .. versionadded:: 2.4
    609 
    610 
    611 .. cfunction:: void PyEval_AcquireLock()
    612 
    613    Acquire the global interpreter lock.  The lock must have been created earlier.
    614    If this thread already has the lock, a deadlock ensues.  This function is not
    615    available when thread support is disabled at compile time.
    616 
    617 
    618 .. cfunction:: void PyEval_ReleaseLock()
    619 
    620    Release the global interpreter lock.  The lock must have been created earlier.
    621    This function is not available when thread support is disabled at compile time.
    622 
    623 
    624 .. cfunction:: void PyEval_AcquireThread(PyThreadState *tstate)
    625 
    626    Acquire the global interpreter lock and set the current thread state to
    627    *tstate*, which should not be *NULL*.  The lock must have been created earlier.
    628    If this thread already has the lock, deadlock ensues.  This function is not
    629    available when thread support is disabled at compile time.
    630 
    631 
    632 .. cfunction:: void PyEval_ReleaseThread(PyThreadState *tstate)
    633 
    634    Reset the current thread state to *NULL* and release the global interpreter
    635    lock.  The lock must have been created earlier and must be held by the current
    636    thread.  The *tstate* argument, which must not be *NULL*, is only used to check
    637    that it represents the current thread state --- if it isn't, a fatal error is
    638    reported. This function is not available when thread support is disabled at
    639    compile time.
    640 
    641 
    642 .. cfunction:: PyThreadState* PyEval_SaveThread()
    643 
    644    Release the global interpreter lock (if it has been created and thread
    645    support is enabled) and reset the thread state to *NULL*, returning the
    646    previous thread state (which is not *NULL*).  If the lock has been created,
    647    the current thread must have acquired it.  (This function is available even
    648    when thread support is disabled at compile time.)
    649 
    650 
    651 .. cfunction:: void PyEval_RestoreThread(PyThreadState *tstate)
    652 
    653    Acquire the global interpreter lock (if it has been created and thread
    654    support is enabled) and set the thread state to *tstate*, which must not be
    655    *NULL*.  If the lock has been created, the current thread must not have
    656    acquired it, otherwise deadlock ensues.  (This function is available even
    657    when thread support is disabled at compile time.)
    658 
    659 
    660 .. cfunction:: void PyEval_ReInitThreads()
    661 
    662    This function is called from :cfunc:`PyOS_AfterFork` to ensure that newly
    663    created child processes don't hold locks referring to threads which
    664    are not running in the child process.
    665 
    666 
    667 The following macros are normally used without a trailing semicolon; look for
    668 example usage in the Python source distribution.
    669 
    670 
    671 .. cmacro:: Py_BEGIN_ALLOW_THREADS
    672 
    673    This macro expands to ``{ PyThreadState *_save; _save = PyEval_SaveThread();``.
    674    Note that it contains an opening brace; it must be matched with a following
    675    :cmacro:`Py_END_ALLOW_THREADS` macro.  See above for further discussion of this
    676    macro.  It is a no-op when thread support is disabled at compile time.
    677 
    678 
    679 .. cmacro:: Py_END_ALLOW_THREADS
    680 
    681    This macro expands to ``PyEval_RestoreThread(_save); }``. Note that it contains
    682    a closing brace; it must be matched with an earlier
    683    :cmacro:`Py_BEGIN_ALLOW_THREADS` macro.  See above for further discussion of
    684    this macro.  It is a no-op when thread support is disabled at compile time.
    685 
    686 
    687 .. cmacro:: Py_BLOCK_THREADS
    688 
    689    This macro expands to ``PyEval_RestoreThread(_save);``: it is equivalent to
    690    :cmacro:`Py_END_ALLOW_THREADS` without the closing brace.  It is a no-op when
    691    thread support is disabled at compile time.
    692 
    693 
    694 .. cmacro:: Py_UNBLOCK_THREADS
    695 
    696    This macro expands to ``_save = PyEval_SaveThread();``: it is equivalent to
    697    :cmacro:`Py_BEGIN_ALLOW_THREADS` without the opening brace and variable
    698    declaration.  It is a no-op when thread support is disabled at compile time.
    699 
    700 All of the following functions are only available when thread support is enabled
    701 at compile time, and must be called only when the global interpreter lock has
    702 been created.
    703 
    704 
    705 .. cfunction:: PyInterpreterState* PyInterpreterState_New()
    706 
    707    Create a new interpreter state object.  The global interpreter lock need not
    708    be held, but may be held if it is necessary to serialize calls to this
    709    function.
    710 
    711 
    712 .. cfunction:: void PyInterpreterState_Clear(PyInterpreterState *interp)
    713 
    714    Reset all information in an interpreter state object.  The global interpreter
    715    lock must be held.
    716 
    717 
    718 .. cfunction:: void PyInterpreterState_Delete(PyInterpreterState *interp)
    719 
    720    Destroy an interpreter state object.  The global interpreter lock need not be
    721    held.  The interpreter state must have been reset with a previous call to
    722    :cfunc:`PyInterpreterState_Clear`.
    723 
    724 
    725 .. cfunction:: PyThreadState* PyThreadState_New(PyInterpreterState *interp)
    726 
    727    Create a new thread state object belonging to the given interpreter object.
    728    The global interpreter lock need not be held, but may be held if it is
    729    necessary to serialize calls to this function.
    730 
    731 
    732 .. cfunction:: void PyThreadState_Clear(PyThreadState *tstate)
    733 
    734    Reset all information in a thread state object.  The global interpreter lock
    735    must be held.
    736 
    737 
    738 .. cfunction:: void PyThreadState_Delete(PyThreadState *tstate)
    739 
    740    Destroy a thread state object.  The global interpreter lock need not be held.
    741    The thread state must have been reset with a previous call to
    742    :cfunc:`PyThreadState_Clear`.
    743 
    744 
    745 .. cfunction:: PyThreadState* PyThreadState_Get()
    746 
    747    Return the current thread state.  The global interpreter lock must be held.
    748    When the current thread state is *NULL*, this issues a fatal error (so that
    749    the caller needn't check for *NULL*).
    750 
    751 
    752 .. cfunction:: PyThreadState* PyThreadState_Swap(PyThreadState *tstate)
    753 
    754    Swap the current thread state with the thread state given by the argument
    755    *tstate*, which may be *NULL*.  The global interpreter lock must be held.
    756 
    757 
    758 .. cfunction:: PyObject* PyThreadState_GetDict()
    759 
    760    Return a dictionary in which extensions can store thread-specific state
    761    information.  Each extension should use a unique key to use to store state in
    762    the dictionary.  It is okay to call this function when no current thread state
    763    is available. If this function returns *NULL*, no exception has been raised and
    764    the caller should assume no current thread state is available.
    765 
    766    .. versionchanged:: 2.3
    767       Previously this could only be called when a current thread is active, and *NULL*
    768       meant that an exception was raised.
    769 
    770 
    771 .. cfunction:: int PyThreadState_SetAsyncExc(long id, PyObject *exc)
    772 
    773    Asynchronously raise an exception in a thread. The *id* argument is the thread
    774    id of the target thread; *exc* is the exception object to be raised. This
    775    function does not steal any references to *exc*. To prevent naive misuse, you
    776    must write your own C extension to call this.  Must be called with the GIL held.
    777    Returns the number of thread states modified; this is normally one, but will be
    778    zero if the thread id isn't found.  If *exc* is :const:`NULL`, the pending
    779    exception (if any) for the thread is cleared. This raises no exceptions.
    780 
    781    .. versionadded:: 2.3
    782 
    783 
    784 .. cfunction:: PyGILState_STATE PyGILState_Ensure()
    785 
    786    Ensure that the current thread is ready to call the Python C API regardless
    787    of the current state of Python, or of the global interpreter lock. This may
    788    be called as many times as desired by a thread as long as each call is
    789    matched with a call to :cfunc:`PyGILState_Release`. In general, other
    790    thread-related APIs may be used between :cfunc:`PyGILState_Ensure` and
    791    :cfunc:`PyGILState_Release` calls as long as the thread state is restored to
    792    its previous state before the Release().  For example, normal usage of the
    793    :cmacro:`Py_BEGIN_ALLOW_THREADS` and :cmacro:`Py_END_ALLOW_THREADS` macros is
    794    acceptable.
    795 
    796    The return value is an opaque "handle" to the thread state when
    797    :cfunc:`PyGILState_Ensure` was called, and must be passed to
    798    :cfunc:`PyGILState_Release` to ensure Python is left in the same state. Even
    799    though recursive calls are allowed, these handles *cannot* be shared - each
    800    unique call to :cfunc:`PyGILState_Ensure` must save the handle for its call
    801    to :cfunc:`PyGILState_Release`.
    802 
    803    When the function returns, the current thread will hold the GIL. Failure is a
    804    fatal error.
    805 
    806    .. versionadded:: 2.3
    807 
    808 
    809 .. cfunction:: void PyGILState_Release(PyGILState_STATE)
    810 
    811    Release any resources previously acquired.  After this call, Python's state will
    812    be the same as it was prior to the corresponding :cfunc:`PyGILState_Ensure` call
    813    (but generally this state will be unknown to the caller, hence the use of the
    814    GILState API.)
    815 
    816    Every call to :cfunc:`PyGILState_Ensure` must be matched by a call to
    817    :cfunc:`PyGILState_Release` on the same thread.
    818 
    819    .. versionadded:: 2.3
     879Bugs and caveats
     880----------------
     881
     882Because sub-interpreters (and the main interpreter) are part of the same
     883process, the insulation between them isn't perfect --- for example, using
     884low-level file operations like  :func:`os.close` they can
     885(accidentally or maliciously) affect each other's open files.  Because of the
     886way extensions are shared between (sub-)interpreters, some extensions may not
     887work properly; this is especially likely when the extension makes use of
     888(static) global variables, or when the extension manipulates its module's
     889dictionary after its initialization.  It is possible to insert objects created
     890in one sub-interpreter into a namespace of another sub-interpreter; this should
     891be done with great care to avoid sharing user-defined functions, methods,
     892instances or classes between sub-interpreters, since import operations executed
     893by such objects may affect the wrong (sub-)interpreter's dictionary of loaded
     894modules.
     895
     896Also note that combining this functionality with :c:func:`PyGILState_\*` APIs
     897is delicate, because these APIs assume a bijection between Python thread states
     898and OS-level threads, an assumption broken by the presence of sub-interpreters.
     899It is highly recommended that you don't switch sub-interpreters between a pair
     900of matching :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release` calls.
     901Furthermore, extensions (such as :mod:`ctypes`) using these APIs to allow calling
     902of Python code from non-Python created threads will probably be broken when using
     903sub-interpreters.
     904
     905
     906Asynchronous Notifications
     907==========================
     908
     909A mechanism is provided to make asynchronous notifications to the main
     910interpreter thread.  These notifications take the form of a function
     911pointer and a void pointer argument.
     912
     913
     914.. c:function:: int Py_AddPendingCall(int (*func)(void *), void *arg)
     915
     916   .. index:: single: Py_AddPendingCall()
     917
     918   Schedule a function to be called from the main interpreter thread.  On
     919   success, 0 is returned and *func* is queued for being called in the
     920   main thread.  On failure, -1 is returned without setting any exception.
     921
     922   When successfully queued, *func* will be *eventually* called from the
     923   main interpreter thread with the argument *arg*.  It will be called
     924   asynchronously with respect to normally running Python code, but with
     925   both these conditions met:
     926
     927   * on a :term:`bytecode` boundary;
     928   * with the main thread holding the :term:`global interpreter lock`
     929     (*func* can therefore use the full C API).
     930
     931   *func* must return 0 on success, or -1 on failure with an exception
     932   set.  *func* won't be interrupted to perform another asynchronous
     933   notification recursively, but it can still be interrupted to switch
     934   threads if the global interpreter lock is released.
     935
     936   This function doesn't need a current thread state to run, and it doesn't
     937   need the global interpreter lock.
     938
     939   .. warning::
     940      This is a low-level function, only useful for very special cases.
     941      There is no guarantee that *func* will be called as quick as
     942      possible.  If the main thread is busy executing a system call,
     943      *func* won't be called before the system call returns.  This
     944      function is generally **not** suitable for calling Python code from
     945      arbitrary C threads.  Instead, use the :ref:`PyGILState API<gilstate>`.
     946
     947   .. versionadded:: 2.7
    820948
    821949
     
    842970
    843971
    844 .. ctype:: int (*Py_tracefunc)(PyObject *obj, PyFrameObject *frame, int what, PyObject *arg)
    845 
    846    The type of the trace function registered using :cfunc:`PyEval_SetProfile` and
    847    :cfunc:`PyEval_SetTrace`. The first parameter is the object passed to the
     972.. c:type:: int (*Py_tracefunc)(PyObject *obj, PyFrameObject *frame, int what, PyObject *arg)
     973
     974   The type of the trace function registered using :c:func:`PyEval_SetProfile` and
     975   :c:func:`PyEval_SetTrace`. The first parameter is the object passed to the
    848976   registration function as *obj*, *frame* is the frame object to which the event
    849977   pertains, *what* is one of the constants :const:`PyTrace_CALL`,
     
    862990   | :const:`PyTrace_LINE`        | Always *NULL*.                       |
    863991   +------------------------------+--------------------------------------+
    864    | :const:`PyTrace_RETURN`      | Value being returned to the caller.  |
     992   | :const:`PyTrace_RETURN`      | Value being returned to the caller,  |
     993   |                              | or *NULL* if caused by an exception. |
    865994   +------------------------------+--------------------------------------+
    866    | :const:`PyTrace_C_CALL`      | Name of function being called.       |
     995   | :const:`PyTrace_C_CALL`      | Function object being called.        |
    867996   +------------------------------+--------------------------------------+
    868    | :const:`PyTrace_C_EXCEPTION` | Always *NULL*.                       |
     997   | :const:`PyTrace_C_EXCEPTION` | Function object being called.        |
    869998   +------------------------------+--------------------------------------+
    870    | :const:`PyTrace_C_RETURN`    | Always *NULL*.                       |
     999   | :const:`PyTrace_C_RETURN`    | Function object being called.        |
    8711000   +------------------------------+--------------------------------------+
    8721001
    8731002
    874 .. cvar:: int PyTrace_CALL
    875 
    876    The value of the *what* parameter to a :ctype:`Py_tracefunc` function when a new
     1003.. c:var:: int PyTrace_CALL
     1004
     1005   The value of the *what* parameter to a :c:type:`Py_tracefunc` function when a new
    8771006   call to a function or method is being reported, or a new entry into a generator.
    8781007   Note that the creation of the iterator for a generator function is not reported
     
    8811010
    8821011
    883 .. cvar:: int PyTrace_EXCEPTION
    884 
    885    The value of the *what* parameter to a :ctype:`Py_tracefunc` function when an
     1012.. c:var:: int PyTrace_EXCEPTION
     1013
     1014   The value of the *what* parameter to a :c:type:`Py_tracefunc` function when an
    8861015   exception has been raised.  The callback function is called with this value for
    8871016   *what* when after any bytecode is processed after which the exception becomes
     
    8921021
    8931022
    894 .. cvar:: int PyTrace_LINE
     1023.. c:var:: int PyTrace_LINE
    8951024
    8961025   The value passed as the *what* parameter to a trace function (but not a
     
    8981027
    8991028
    900 .. cvar:: int PyTrace_RETURN
    901 
    902    The value for the *what* parameter to :ctype:`Py_tracefunc` functions when a
     1029.. c:var:: int PyTrace_RETURN
     1030
     1031   The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a
    9031032   call is returning without propagating an exception.
    9041033
    9051034
    906 .. cvar:: int PyTrace_C_CALL
    907 
    908    The value for the *what* parameter to :ctype:`Py_tracefunc` functions when a C
     1035.. c:var:: int PyTrace_C_CALL
     1036
     1037   The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a C
    9091038   function is about to be called.
    9101039
    9111040
    912 .. cvar:: int PyTrace_C_EXCEPTION
    913 
    914    The value for the *what* parameter to :ctype:`Py_tracefunc` functions when a C
    915    function has thrown an exception.
    916 
    917 
    918 .. cvar:: int PyTrace_C_RETURN
    919 
    920    The value for the *what* parameter to :ctype:`Py_tracefunc` functions when a C
     1041.. c:var:: int PyTrace_C_EXCEPTION
     1042
     1043   The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a C
     1044   function has raised an exception.
     1045
     1046
     1047.. c:var:: int PyTrace_C_RETURN
     1048
     1049   The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a C
    9211050   function has returned.
    9221051
    9231052
    924 .. cfunction:: void PyEval_SetProfile(Py_tracefunc func, PyObject *obj)
     1053.. c:function:: void PyEval_SetProfile(Py_tracefunc func, PyObject *obj)
    9251054
    9261055   Set the profiler function to *func*.  The *obj* parameter is passed to the
     
    9321061
    9331062
    934 .. cfunction:: void PyEval_SetTrace(Py_tracefunc func, PyObject *obj)
     1063.. c:function:: void PyEval_SetTrace(Py_tracefunc func, PyObject *obj)
    9351064
    9361065   Set the tracing function to *func*.  This is similar to
    937    :cfunc:`PyEval_SetProfile`, except the tracing function does receive line-number
     1066   :c:func:`PyEval_SetProfile`, except the tracing function does receive line-number
    9381067   events.
    9391068
    940 .. cfunction:: PyObject* PyEval_GetCallStats(PyObject *self)
     1069.. c:function:: PyObject* PyEval_GetCallStats(PyObject *self)
    9411070
    9421071   Return a tuple of function call counts.  There are constants defined for the
     
    9901119
    9911120
    992 .. cfunction:: PyInterpreterState* PyInterpreterState_Head()
     1121.. c:function:: PyInterpreterState* PyInterpreterState_Head()
    9931122
    9941123   Return the interpreter state object at the head of the list of all such objects.
     
    9971126
    9981127
    999 .. cfunction:: PyInterpreterState* PyInterpreterState_Next(PyInterpreterState *interp)
     1128.. c:function:: PyInterpreterState* PyInterpreterState_Next(PyInterpreterState *interp)
    10001129
    10011130   Return the next interpreter state object after *interp* from the list of all
     
    10051134
    10061135
    1007 .. cfunction:: PyThreadState * PyInterpreterState_ThreadHead(PyInterpreterState *interp)
    1008 
    1009    Return the a pointer to the first :ctype:`PyThreadState` object in the list of
     1136.. c:function:: PyThreadState * PyInterpreterState_ThreadHead(PyInterpreterState *interp)
     1137
     1138   Return the a pointer to the first :c:type:`PyThreadState` object in the list of
    10101139   threads associated with the interpreter *interp*.
    10111140
     
    10131142
    10141143
    1015 .. cfunction:: PyThreadState* PyThreadState_Next(PyThreadState *tstate)
     1144.. c:function:: PyThreadState* PyThreadState_Next(PyThreadState *tstate)
    10161145
    10171146   Return the next thread state object after *tstate* from the list of all such
    1018    objects belonging to the same :ctype:`PyInterpreterState` object.
     1147   objects belonging to the same :c:type:`PyInterpreterState` object.
    10191148
    10201149   .. versionadded:: 2.2
  • python/vendor/current/Doc/c-api/int.rst

    r2 r388  
    99
    1010
    11 .. ctype:: PyIntObject
     11.. c:type:: PyIntObject
    1212
    13    This subtype of :ctype:`PyObject` represents a Python integer object.
     13   This subtype of :c:type:`PyObject` represents a Python integer object.
    1414
    1515
    16 .. cvar:: PyTypeObject PyInt_Type
     16.. c:var:: PyTypeObject PyInt_Type
    1717
    1818   .. index:: single: IntType (in modules types)
    1919
    20    This instance of :ctype:`PyTypeObject` represents the Python plain integer type.
     20   This instance of :c:type:`PyTypeObject` represents the Python plain integer type.
    2121   This is the same object as ``int`` and ``types.IntType``.
    2222
    2323
    24 .. cfunction:: int PyInt_Check(PyObject *o)
     24.. c:function:: int PyInt_Check(PyObject *o)
    2525
    26    Return true if *o* is of type :cdata:`PyInt_Type` or a subtype of
    27    :cdata:`PyInt_Type`.
     26   Return true if *o* is of type :c:data:`PyInt_Type` or a subtype of
     27   :c:data:`PyInt_Type`.
    2828
    2929   .. versionchanged:: 2.2
     
    3131
    3232
    33 .. cfunction:: int PyInt_CheckExact(PyObject *o)
     33.. c:function:: int PyInt_CheckExact(PyObject *o)
    3434
    35    Return true if *o* is of type :cdata:`PyInt_Type`, but not a subtype of
    36    :cdata:`PyInt_Type`.
     35   Return true if *o* is of type :c:data:`PyInt_Type`, but not a subtype of
     36   :c:data:`PyInt_Type`.
    3737
    3838   .. versionadded:: 2.2
    3939
    4040
    41 .. cfunction:: PyObject* PyInt_FromString(char *str, char **pend, int base)
     41.. c:function:: PyObject* PyInt_FromString(char *str, char **pend, int base)
    4242
    43    Return a new :ctype:`PyIntObject` or :ctype:`PyLongObject` based on the string
     43   Return a new :c:type:`PyIntObject` or :c:type:`PyLongObject` based on the string
    4444   value in *str*, which is interpreted according to the radix in *base*.  If
    4545   *pend* is non-*NULL*, ``*pend`` will point to the first character in *str* which
     
    5050   must be between ``2`` and ``36``, inclusive.  Leading spaces are ignored.  If
    5151   there are no digits, :exc:`ValueError` will be raised.  If the string represents
    52    a number too large to be contained within the machine's :ctype:`long int` type
    53    and overflow warnings are being suppressed, a :ctype:`PyLongObject` will be
     52   a number too large to be contained within the machine's :c:type:`long int` type
     53   and overflow warnings are being suppressed, a :c:type:`PyLongObject` will be
    5454   returned.  If overflow warnings are not being suppressed, *NULL* will be
    5555   returned in this case.
    5656
    5757
    58 .. cfunction:: PyObject* PyInt_FromLong(long ival)
     58.. c:function:: PyObject* PyInt_FromLong(long ival)
    5959
    6060   Create a new integer object with a value of *ival*.
     
    6767
    6868
    69 .. cfunction:: PyObject* PyInt_FromSsize_t(Py_ssize_t ival)
     69.. c:function:: PyObject* PyInt_FromSsize_t(Py_ssize_t ival)
    7070
    7171   Create a new integer object with a value of *ival*. If the value is larger
     
    7676
    7777
    78 .. cfunction:: PyObject* PyInt_FromSize_t(size_t ival)
     78.. c:function:: PyObject* PyInt_FromSize_t(size_t ival)
    7979
    8080   Create a new integer object with a value of *ival*. If the value exceeds
     
    8484
    8585
    86 .. cfunction:: long PyInt_AsLong(PyObject *io)
     86.. c:function:: long PyInt_AsLong(PyObject *io)
    8787
    88    Will first attempt to cast the object to a :ctype:`PyIntObject`, if it is not
     88   Will first attempt to cast the object to a :c:type:`PyIntObject`, if it is not
    8989   already one, and then return its value. If there is an error, ``-1`` is
    9090   returned, and the caller should check ``PyErr_Occurred()`` to find out whether
     
    9292
    9393
    94 .. cfunction:: long PyInt_AS_LONG(PyObject *io)
     94.. c:function:: long PyInt_AS_LONG(PyObject *io)
    9595
    9696   Return the value of the object *io*.  No error checking is performed.
    9797
    9898
    99 .. cfunction:: unsigned long PyInt_AsUnsignedLongMask(PyObject *io)
     99.. c:function:: unsigned long PyInt_AsUnsignedLongMask(PyObject *io)
    100100
    101    Will first attempt to cast the object to a :ctype:`PyIntObject` or
    102    :ctype:`PyLongObject`, if it is not already one, and then return its value as
     101   Will first attempt to cast the object to a :c:type:`PyIntObject` or
     102   :c:type:`PyLongObject`, if it is not already one, and then return its value as
    103103   unsigned long.  This function does not check for overflow.
    104104
     
    106106
    107107
    108 .. cfunction:: unsigned PY_LONG_LONG PyInt_AsUnsignedLongLongMask(PyObject *io)
     108.. c:function:: unsigned PY_LONG_LONG PyInt_AsUnsignedLongLongMask(PyObject *io)
    109109
    110    Will first attempt to cast the object to a :ctype:`PyIntObject` or
    111    :ctype:`PyLongObject`, if it is not already one, and then return its value as
     110   Will first attempt to cast the object to a :c:type:`PyIntObject` or
     111   :c:type:`PyLongObject`, if it is not already one, and then return its value as
    112112   unsigned long long, without checking for overflow.
    113113
     
    115115
    116116
    117 .. cfunction:: Py_ssize_t PyInt_AsSsize_t(PyObject *io)
     117.. c:function:: Py_ssize_t PyInt_AsSsize_t(PyObject *io)
    118118
    119    Will first attempt to cast the object to a :ctype:`PyIntObject` or
    120    :ctype:`PyLongObject`, if it is not already one, and then return its value as
    121    :ctype:`Py_ssize_t`.
     119   Will first attempt to cast the object to a :c:type:`PyIntObject` or
     120   :c:type:`PyLongObject`, if it is not already one, and then return its value as
     121   :c:type:`Py_ssize_t`.
    122122
    123123   .. versionadded:: 2.5
    124124
    125125
    126 .. cfunction:: long PyInt_GetMax()
     126.. c:function:: long PyInt_GetMax()
    127127
    128128   .. index:: single: LONG_MAX
     
    132132
    133133
    134 .. cfunction:: int PyInt_ClearFreeList()
     134.. c:function:: int PyInt_ClearFreeList()
    135135
    136136   Clear the integer free list. Return the number of items that could not
  • python/vendor/current/Doc/c-api/intro.rst

    r2 r388  
    4242
    4343This implies inclusion of the following standard headers: ``<stdio.h>``,
    44 ``<string.h>``, ``<errno.h>``, ``<limits.h>``, and ``<stdlib.h>`` (if
    45 available).
     44``<string.h>``, ``<errno.h>``, ``<limits.h>``, ``<assert.h>`` and ``<stdlib.h>``
     45(if available).
    4646
    4747.. note::
     
    8989
    9090Most Python/C API functions have one or more arguments as well as a return value
    91 of type :ctype:`PyObject\*`.  This type is a pointer to an opaque data type
     91of type :c:type:`PyObject\*`.  This type is a pointer to an opaque data type
    9292representing an arbitrary Python object.  Since all Python object types are
    9393treated the same way by the Python language in most situations (e.g.,
     
    9595should be represented by a single C type.  Almost all Python objects live on the
    9696heap: you never declare an automatic or static variable of type
    97 :ctype:`PyObject`, only pointer variables of type :ctype:`PyObject\*` can  be
     97:c:type:`PyObject`, only pointer variables of type :c:type:`PyObject\*` can  be
    9898declared.  The sole exception are the type objects; since these must never be
    99 deallocated, they are typically static :ctype:`PyTypeObject` objects.
     99deallocated, they are typically static :c:type:`PyTypeObject` objects.
    100100
    101101All Python objects (even Python integers) have a :dfn:`type` and a
     
    128128
    129129Reference counts are always manipulated explicitly.  The normal way is  to use
    130 the macro :cfunc:`Py_INCREF` to increment an object's reference count by one,
    131 and :cfunc:`Py_DECREF` to decrement it by   one.  The :cfunc:`Py_DECREF` macro
     130the macro :c:func:`Py_INCREF` to increment an object's reference count by one,
     131and :c:func:`Py_DECREF` to decrement it by   one.  The :c:func:`Py_DECREF` macro
    132132is considerably more complex than the incref one, since it must check whether
    133133the reference count becomes zero and then cause the object's deallocator to be
     
    160160and possible deallocating it. The real danger is that innocent-looking
    161161operations may invoke arbitrary Python code which could do this; there is a code
    162 path which allows control to flow back to the user from a :cfunc:`Py_DECREF`, so
     162path which allows control to flow back to the user from a :c:func:`Py_DECREF`, so
    163163almost any operation is potentially dangerous.
    164164
     
    166166begins with ``PyObject_``, ``PyNumber_``, ``PySequence_`` or ``PyMapping_``).
    167167These operations always increment the reference count of the object they return.
    168 This leaves the caller with the responsibility to call :cfunc:`Py_DECREF` when
     168This leaves the caller with the responsibility to call :c:func:`Py_DECREF` when
    169169they are done with the result; this soon becomes second nature.
    170170
     
    181181reference is no longer needed.  Ownership can also be transferred, meaning that
    182182the code that receives ownership of the reference then becomes responsible for
    183 eventually decref'ing it by calling :cfunc:`Py_DECREF` or :cfunc:`Py_XDECREF`
     183eventually decref'ing it by calling :c:func:`Py_DECREF` or :c:func:`Py_XDECREF`
    184184when it's no longer needed---or passing on this responsibility (usually to its
    185185caller). When a function passes ownership of a reference on to its caller, the
     
    199199
    200200Few functions steal references; the two notable exceptions are
    201 :cfunc:`PyList_SetItem` and :cfunc:`PyTuple_SetItem`, which  steal a reference
     201:c:func:`PyList_SetItem` and :c:func:`PyTuple_SetItem`, which  steal a reference
    202202to the item (but not to the tuple or list into which the item is put!).  These
    203203functions were designed to steal a reference because of a common idiom for
     
    213213   PyTuple_SetItem(t, 2, PyString_FromString("three"));
    214214
    215 Here, :cfunc:`PyInt_FromLong` returns a new reference which is immediately
    216 stolen by :cfunc:`PyTuple_SetItem`.  When you want to keep using an object
    217 although the reference to it will be stolen, use :cfunc:`Py_INCREF` to grab
     215Here, :c:func:`PyInt_FromLong` returns a new reference which is immediately
     216stolen by :c:func:`PyTuple_SetItem`.  When you want to keep using an object
     217although the reference to it will be stolen, use :c:func:`Py_INCREF` to grab
    218218another reference before calling the reference-stealing function.
    219219
    220 Incidentally, :cfunc:`PyTuple_SetItem` is the *only* way to set tuple items;
    221 :cfunc:`PySequence_SetItem` and :cfunc:`PyObject_SetItem` refuse to do this
     220Incidentally, :c:func:`PyTuple_SetItem` is the *only* way to set tuple items;
     221:c:func:`PySequence_SetItem` and :c:func:`PyObject_SetItem` refuse to do this
    222222since tuples are an immutable data type.  You should only use
    223 :cfunc:`PyTuple_SetItem` for tuples that you are creating yourself.
    224 
    225 Equivalent code for populating a list can be written using :cfunc:`PyList_New`
    226 and :cfunc:`PyList_SetItem`.
     223:c:func:`PyTuple_SetItem` for tuples that you are creating yourself.
     224
     225Equivalent code for populating a list can be written using :c:func:`PyList_New`
     226and :c:func:`PyList_SetItem`.
    227227
    228228However, in practice, you will rarely use these ways of creating and populating
    229 a tuple or list.  There's a generic function, :cfunc:`Py_BuildValue`, that can
     229a tuple or list.  There's a generic function, :c:func:`Py_BuildValue`, that can
    230230create most common objects from C values, directed by a :dfn:`format string`.
    231231For example, the above two blocks of code could be replaced by the following
     
    237237   list = Py_BuildValue("[iis]", 1, 2, "three");
    238238
    239 It is much more common to use :cfunc:`PyObject_SetItem` and friends with items
     239It is much more common to use :c:func:`PyObject_SetItem` and friends with items
    240240whose references you are only borrowing, like arguments that were passed in to
    241241the function you are writing.  In that case, their behaviour regarding reference
     
    256256           if (!index)
    257257               return -1;
    258            if (PyObject_SetItem(target, index, item) < 0)
     258           if (PyObject_SetItem(target, index, item) < 0) {
     259               Py_DECREF(index);
    259260               return -1;
     261       }
    260262           Py_DECREF(index);
    261263       }
     
    271273returned object is created  on the fly, and the reference you get is the only
    272274reference to the  object.  Therefore, the generic functions that return object
    273 references, like :cfunc:`PyObject_GetItem` and  :cfunc:`PySequence_GetItem`,
     275references, like :c:func:`PyObject_GetItem` and  :c:func:`PySequence_GetItem`,
    274276always return a new reference (the caller becomes the owner of the reference).
    275277
     
    277279function depends on which function you call only --- *the plumage* (the type of
    278280the object passed as an argument to the function) *doesn't enter into it!*
    279 Thus, if you  extract an item from a list using :cfunc:`PyList_GetItem`, you
     281Thus, if you  extract an item from a list using :c:func:`PyList_GetItem`, you
    280282don't own the reference --- but if you obtain the same item from the same list
    281 using :cfunc:`PySequence_GetItem` (which happens to take exactly the same
     283using :c:func:`PySequence_GetItem` (which happens to take exactly the same
    282284arguments), you do own a reference to the returned object.
    283285
     
    287289
    288290Here is an example of how you could write a function that computes the sum of
    289 the items in a list of integers; once using  :cfunc:`PyList_GetItem`, and once
    290 using :cfunc:`PySequence_GetItem`. ::
     291the items in a list of integers; once using  :c:func:`PyList_GetItem`, and once
     292using :c:func:`PySequence_GetItem`. ::
    291293
    292294   long
     
    341343
    342344There are few other data types that play a significant role in  the Python/C
    343 API; most are simple C types such as :ctype:`int`,  :ctype:`long`,
    344 :ctype:`double` and :ctype:`char\*`.  A few structure types  are used to
     345API; most are simple C types such as :c:type:`int`,  :c:type:`long`,
     346:c:type:`double` and :c:type:`char\*`.  A few structure types  are used to
    345347describe static tables used to list the functions exported  by a module or the
    346348data attributes of a new object type, and another is used to describe the value
     
    362364.. index:: single: PyErr_Occurred()
    363365
    364 For C programmers, however, error checking always has to be explicit.   All
    365 functions in the Python/C API can raise exceptions, unless an  explicit claim is
    366 made otherwise in a function's documentation.  In  general, when a function
    367 encounters an error, it sets an exception,  discards any object references that
    368 it owns, and returns an  error indicator --- usually *NULL* or ``-1``.  A few
    369 functions  return a Boolean true/false result, with false indicating an error.
    370 Very few functions return no explicit error indicator or have an  ambiguous
    371 return value, and require explicit testing for errors with
    372 :cfunc:`PyErr_Occurred`.
     366For C programmers, however, error checking always has to be explicit.  All
     367functions in the Python/C API can raise exceptions, unless an explicit claim is
     368made otherwise in a function's documentation.  In general, when a function
     369encounters an error, it sets an exception, discards any object references that
     370it owns, and returns an error indicator.  If not documented otherwise, this
     371indicator is either *NULL* or ``-1``, depending on the function's return type.
     372A few functions return a Boolean true/false result, with false indicating an
     373error.  Very few functions return no explicit error indicator or have an
     374ambiguous return value, and require explicit testing for errors with
     375:c:func:`PyErr_Occurred`.  These exceptions are always explicitly documented.
    373376
    374377.. index::
     
    379382using global storage in an unthreaded application).  A  thread can be in one of
    380383two states: an exception has occurred, or not. The function
    381 :cfunc:`PyErr_Occurred` can be used to check for this: it returns a borrowed
     384:c:func:`PyErr_Occurred` can be used to check for this: it returns a borrowed
    382385reference to the exception type object when an exception has occurred, and
    383386*NULL* otherwise.  There are a number of functions to set the exception state:
    384 :cfunc:`PyErr_SetString` is the most common (though not the most general)
    385 function to set the exception state, and :cfunc:`PyErr_Clear` clears the
     387:c:func:`PyErr_SetString` is the most common (though not the most general)
     388function to set the exception state, and :c:func:`PyErr_Clear` clears the
    386389exception state.
    387390
     
    424427
    425428A simple example of detecting exceptions and passing them on is shown in the
    426 :cfunc:`sum_sequence` example above.  It so happens that that example doesn't
     429:c:func:`sum_sequence` example above.  It so happens that this example doesn't
    427430need to clean up any owned references when it detects an error.  The following
    428431example function shows some error cleanup.  First, to remind you why you like
     
    491494
    492495This example represents an endorsed use of the ``goto`` statement  in C!
    493 It illustrates the use of :cfunc:`PyErr_ExceptionMatches` and
    494 :cfunc:`PyErr_Clear` to handle specific exceptions, and the use of
    495 :cfunc:`Py_XDECREF` to dispose of owned references that may be *NULL* (note the
    496 ``'X'`` in the name; :cfunc:`Py_DECREF` would crash when confronted with a
     496It illustrates the use of :c:func:`PyErr_ExceptionMatches` and
     497:c:func:`PyErr_Clear` to handle specific exceptions, and the use of
     498:c:func:`Py_XDECREF` to dispose of owned references that may be *NULL* (note the
     499``'X'`` in the name; :c:func:`Py_DECREF` would crash when confronted with a
    497500*NULL* reference).  It is important that the variables used to hold owned
    498501references are initialized to *NULL* for this to work; likewise, the proposed
     
    520523   single: path (in module sys)
    521524
    522 The basic initialization function is :cfunc:`Py_Initialize`. This initializes
     525The basic initialization function is :c:func:`Py_Initialize`. This initializes
    523526the table of loaded modules, and creates the fundamental modules
    524527:mod:`__builtin__`, :mod:`__main__`, :mod:`sys`, and :mod:`exceptions`.  It also
    525528initializes the module search path (``sys.path``).
    526529
    527 .. index:: single: PySys_SetArgv()
    528 
    529 :cfunc:`Py_Initialize` does not set the "script argument list"  (``sys.argv``).
    530 If this variable is needed by Python code that  will be executed later, it must
    531 be set explicitly with a call to  ``PySys_SetArgv(argc, argv)`` subsequent to
    532 the call to :cfunc:`Py_Initialize`.
     530.. index:: single: PySys_SetArgvEx()
     531
     532:c:func:`Py_Initialize` does not set the "script argument list"  (``sys.argv``).
     533If this variable is needed by Python code that will be executed later, it must
     534be set explicitly with a call to  ``PySys_SetArgvEx(argc, argv, updatepath)``
     535after the call to :c:func:`Py_Initialize`.
    533536
    534537On most systems (in particular, on Unix and Windows, although the details are
    535 slightly different), :cfunc:`Py_Initialize` calculates the module search path
     538slightly different), :c:func:`Py_Initialize` calculates the module search path
    536539based upon its best guess for the location of the standard Python interpreter
    537540executable, assuming that the Python library is found in a fixed location
     
    557560
    558561The embedding application can steer the search by calling
    559 ``Py_SetProgramName(file)`` *before* calling  :cfunc:`Py_Initialize`.  Note that
     562``Py_SetProgramName(file)`` *before* calling  :c:func:`Py_Initialize`.  Note that
    560563:envvar:`PYTHONHOME` still overrides this and :envvar:`PYTHONPATH` is still
    561564inserted in front of the standard path.  An application that requires total
    562 control has to provide its own implementation of :cfunc:`Py_GetPath`,
    563 :cfunc:`Py_GetPrefix`, :cfunc:`Py_GetExecPrefix`, and
    564 :cfunc:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`).
     565control has to provide its own implementation of :c:func:`Py_GetPath`,
     566:c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, and
     567:c:func:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`).
    565568
    566569.. index:: single: Py_IsInitialized()
     
    568571Sometimes, it is desirable to "uninitialize" Python.  For instance,  the
    569572application may want to start over (make another call to
    570 :cfunc:`Py_Initialize`) or the application is simply done with its  use of
     573:c:func:`Py_Initialize`) or the application is simply done with its  use of
    571574Python and wants to free memory allocated by Python.  This can be accomplished
    572 by calling :cfunc:`Py_Finalize`.  The function :cfunc:`Py_IsInitialized` returns
     575by calling :c:func:`Py_Finalize`.  The function :c:func:`Py_IsInitialized` returns
    573576true if Python is currently in the initialized state.  More information about
    574 these functions is given in a later chapter. Notice that :cfunc:`Py_Finalize`
     577these functions is given in a later chapter. Notice that :c:func:`Py_Finalize`
    575578does *not* free all memory allocated by the Python interpreter, e.g. memory
    576579allocated by extension modules currently cannot be released.
     
    592595frequently-used builds will be described in the remainder of this section.
    593596
    594 Compiling the interpreter with the :cmacro:`Py_DEBUG` macro defined produces
    595 what is generally meant by "a debug build" of Python. :cmacro:`Py_DEBUG` is
    596 enabled in the Unix build by adding :option:`--with-pydebug` to the
    597 :file:`configure` command.  It is also implied by the presence of the
    598 not-Python-specific :cmacro:`_DEBUG` macro.  When :cmacro:`Py_DEBUG` is enabled
     597Compiling the interpreter with the :c:macro:`Py_DEBUG` macro defined produces
     598what is generally meant by "a debug build" of Python. :c:macro:`Py_DEBUG` is
     599enabled in the Unix build by adding ``--with-pydebug`` to the
     600:file:`./configure` command.  It is also implied by the presence of the
     601not-Python-specific :c:macro:`_DEBUG` macro.  When :c:macro:`Py_DEBUG` is enabled
    599602in the Unix build, compiler optimization is disabled.
    600603
     
    625628There may be additional checks not mentioned here.
    626629
    627 Defining :cmacro:`Py_TRACE_REFS` enables reference tracing.  When defined, a
     630Defining :c:macro:`Py_TRACE_REFS` enables reference tracing.  When defined, a
    628631circular doubly linked list of active objects is maintained by adding two extra
    629 fields to every :ctype:`PyObject`.  Total allocations are tracked as well.  Upon
     632fields to every :c:type:`PyObject`.  Total allocations are tracked as well.  Upon
    630633exit, all existing references are printed.  (In interactive mode this happens
    631 after every statement run by the interpreter.)  Implied by :cmacro:`Py_DEBUG`.
     634after every statement run by the interpreter.)  Implied by :c:macro:`Py_DEBUG`.
    632635
    633636Please refer to :file:`Misc/SpecialBuilds.txt` in the Python source distribution
  • python/vendor/current/Doc/c-api/iter.rst

    r2 r388  
    88.. versionadded:: 2.2
    99
    10 There are only a couple of functions specifically for working with iterators.
     10There are two functions specifically for working with iterators.
    1111
    1212
    13 .. cfunction:: int PyIter_Check(PyObject *o)
     13.. c:function:: int PyIter_Check(PyObject *o)
    1414
    1515   Return true if the object *o* supports the iterator protocol.
    1616
    1717
    18 .. cfunction:: PyObject* PyIter_Next(PyObject *o)
     18.. c:function:: PyObject* PyIter_Next(PyObject *o)
    1919
    20    Return the next value from the iteration *o*.  If the object is an iterator,
    21    this retrieves the next value from the iteration, and returns *NULL* with no
    22    exception set if there are no remaining items.  If the object is not an
    23    iterator, :exc:`TypeError` is raised, or if there is an error in retrieving the
    24    item, returns *NULL* and passes along the exception.
     20   Return the next value from the iteration *o*.  The object must be an iterator
     21   (it is up to the caller to check this).  If there are no remaining values,
     22   returns *NULL* with no exception set.  If an error occurs while retrieving
     23   the item, returns *NULL* and passes along the exception.
    2524
    2625To write a loop which iterates over an iterator, the C code should look
  • python/vendor/current/Doc/c-api/iterator.rst

    r2 r388  
    1313
    1414
    15 .. cvar:: PyTypeObject PySeqIter_Type
     15.. c:var:: PyTypeObject PySeqIter_Type
    1616
    17    Type object for iterator objects returned by :cfunc:`PySeqIter_New` and the
     17   Type object for iterator objects returned by :c:func:`PySeqIter_New` and the
    1818   one-argument form of the :func:`iter` built-in function for built-in sequence
    1919   types.
     
    2222
    2323
    24 .. cfunction:: int PySeqIter_Check(op)
     24.. c:function:: int PySeqIter_Check(op)
    2525
    26    Return true if the type of *op* is :cdata:`PySeqIter_Type`.
     26   Return true if the type of *op* is :c:data:`PySeqIter_Type`.
    2727
    2828   .. versionadded:: 2.2
    2929
    3030
    31 .. cfunction:: PyObject* PySeqIter_New(PyObject *seq)
     31.. c:function:: PyObject* PySeqIter_New(PyObject *seq)
    3232
    3333   Return an iterator that works with a general sequence object, *seq*.  The
     
    3838
    3939
    40 .. cvar:: PyTypeObject PyCallIter_Type
     40.. c:var:: PyTypeObject PyCallIter_Type
    4141
    42    Type object for iterator objects returned by :cfunc:`PyCallIter_New` and the
     42   Type object for iterator objects returned by :c:func:`PyCallIter_New` and the
    4343   two-argument form of the :func:`iter` built-in function.
    4444
     
    4646
    4747
    48 .. cfunction:: int PyCallIter_Check(op)
     48.. c:function:: int PyCallIter_Check(op)
    4949
    50    Return true if the type of *op* is :cdata:`PyCallIter_Type`.
     50   Return true if the type of *op* is :c:data:`PyCallIter_Type`.
    5151
    5252   .. versionadded:: 2.2
    5353
    5454
    55 .. cfunction:: PyObject* PyCallIter_New(PyObject *callable, PyObject *sentinel)
     55.. c:function:: PyObject* PyCallIter_New(PyObject *callable, PyObject *sentinel)
    5656
    5757   Return a new iterator.  The first parameter, *callable*, can be any Python
  • python/vendor/current/Doc/c-api/list.rst

    r2 r388  
    99
    1010
    11 .. ctype:: PyListObject
     11.. c:type:: PyListObject
    1212
    13    This subtype of :ctype:`PyObject` represents a Python list object.
     13   This subtype of :c:type:`PyObject` represents a Python list object.
    1414
    1515
    16 .. cvar:: PyTypeObject PyList_Type
     16.. c:var:: PyTypeObject PyList_Type
    1717
    18    .. index:: single: ListType (in module types)
    19 
    20    This instance of :ctype:`PyTypeObject` represents the Python list type.
    21    This is the same object as ``list`` and ``types.ListType`` in the Python
    22    layer.
     18   This instance of :c:type:`PyTypeObject` represents the Python list type.  This
     19   is the same object as ``list`` in the Python layer.
    2320
    2421
    25 .. cfunction:: int PyList_Check(PyObject *p)
     22.. c:function:: int PyList_Check(PyObject *p)
    2623
    2724   Return true if *p* is a list object or an instance of a subtype of the list
     
    3229
    3330
    34 .. cfunction:: int PyList_CheckExact(PyObject *p)
     31.. c:function:: int PyList_CheckExact(PyObject *p)
    3532
    3633   Return true if *p* is a list object, but not an instance of a subtype of
     
    4037
    4138
    42 .. cfunction:: PyObject* PyList_New(Py_ssize_t len)
     39.. c:function:: PyObject* PyList_New(Py_ssize_t len)
    4340
    4441   Return a new list of length *len* on success, or *NULL* on failure.
     
    4643   .. note::
    4744
    48       If *length* is greater than zero, the returned list object's items are
     45      If *len* is greater than zero, the returned list object's items are
    4946      set to ``NULL``.  Thus you cannot use abstract API functions such as
    50       :cfunc:`PySequence_SetItem`  or expose the object to Python code before
    51       setting all items to a real object with :cfunc:`PyList_SetItem`.
     47      :c:func:`PySequence_SetItem`  or expose the object to Python code before
     48      setting all items to a real object with :c:func:`PyList_SetItem`.
    5249
    5350   .. versionchanged:: 2.5
    54       This function used an :ctype:`int` for *size*. This might require
     51      This function used an :c:type:`int` for *size*. This might require
    5552      changes in your code for properly supporting 64-bit systems.
    5653
    5754
    58 .. cfunction:: Py_ssize_t PyList_Size(PyObject *list)
     55.. c:function:: Py_ssize_t PyList_Size(PyObject *list)
    5956
    6057   .. index:: builtin: len
     
    6461
    6562   .. versionchanged:: 2.5
    66       This function returned an :ctype:`int`. This might require changes in
     63      This function returned an :c:type:`int`. This might require changes in
    6764      your code for properly supporting 64-bit systems.
    6865
    6966
    70 .. cfunction:: Py_ssize_t PyList_GET_SIZE(PyObject *list)
     67.. c:function:: Py_ssize_t PyList_GET_SIZE(PyObject *list)
    7168
    72    Macro form of :cfunc:`PyList_Size` without error checking.
     69   Macro form of :c:func:`PyList_Size` without error checking.
    7370
    7471   .. versionchanged:: 2.5
    75       This macro returned an :ctype:`int`. This might require changes in your
     72      This macro returned an :c:type:`int`. This might require changes in your
    7673      code for properly supporting 64-bit systems.
    7774
    7875
    79 .. cfunction:: PyObject* PyList_GetItem(PyObject *list, Py_ssize_t index)
     76.. c:function:: PyObject* PyList_GetItem(PyObject *list, Py_ssize_t index)
    8077
    81    Return the object at position *pos* in the list pointed to by *p*.  The
     78   Return the object at position *index* in the list pointed to by *list*.  The
    8279   position must be positive, indexing from the end of the list is not
    83    supported.  If *pos* is out of bounds, return *NULL* and set an
     80   supported.  If *index* is out of bounds, return *NULL* and set an
    8481   :exc:`IndexError` exception.
    8582
    8683   .. versionchanged:: 2.5
    87       This function used an :ctype:`int` for *index*. This might require
     84      This function used an :c:type:`int` for *index*. This might require
    8885      changes in your code for properly supporting 64-bit systems.
    8986
    9087
    91 .. cfunction:: PyObject* PyList_GET_ITEM(PyObject *list, Py_ssize_t i)
     88.. c:function:: PyObject* PyList_GET_ITEM(PyObject *list, Py_ssize_t i)
    9289
    93    Macro form of :cfunc:`PyList_GetItem` without error checking.
     90   Macro form of :c:func:`PyList_GetItem` without error checking.
    9491
    9592   .. versionchanged:: 2.5
    96       This macro used an :ctype:`int` for *i*. This might require changes in
     93      This macro used an :c:type:`int` for *i*. This might require changes in
    9794      your code for properly supporting 64-bit systems.
    9895
    9996
    100 .. cfunction:: int PyList_SetItem(PyObject *list, Py_ssize_t index, PyObject *item)
     97.. c:function:: int PyList_SetItem(PyObject *list, Py_ssize_t index, PyObject *item)
    10198
    10299   Set the item at index *index* in list to *item*.  Return ``0`` on success
     
    109106
    110107   .. versionchanged:: 2.5
    111       This function used an :ctype:`int` for *index*. This might require
     108      This function used an :c:type:`int` for *index*. This might require
    112109      changes in your code for properly supporting 64-bit systems.
    113110
    114111
    115 .. cfunction:: void PyList_SET_ITEM(PyObject *list, Py_ssize_t i, PyObject *o)
     112.. c:function:: void PyList_SET_ITEM(PyObject *list, Py_ssize_t i, PyObject *o)
    116113
    117    Macro form of :cfunc:`PyList_SetItem` without error checking. This is
     114   Macro form of :c:func:`PyList_SetItem` without error checking. This is
    118115   normally only used to fill in new lists where there is no previous content.
    119116
     
    121118
    122119      This macro "steals" a reference to *item*, and, unlike
    123       :cfunc:`PyList_SetItem`, does *not* discard a reference to any item that
     120      :c:func:`PyList_SetItem`, does *not* discard a reference to any item that
    124121      it being replaced; any reference in *list* at position *i* will be
    125122      leaked.
    126123
    127124   .. versionchanged:: 2.5
    128       This macro used an :ctype:`int` for *i*. This might require
     125      This macro used an :c:type:`int` for *i*. This might require
    129126      changes in your code for properly supporting 64-bit systems.
    130127
    131128
    132 .. cfunction:: int PyList_Insert(PyObject *list, Py_ssize_t index, PyObject *item)
     129.. c:function:: int PyList_Insert(PyObject *list, Py_ssize_t index, PyObject *item)
    133130
    134131   Insert the item *item* into list *list* in front of index *index*.  Return
     
    137134
    138135   .. versionchanged:: 2.5
    139       This function used an :ctype:`int` for *index*. This might require
     136      This function used an :c:type:`int` for *index*. This might require
    140137      changes in your code for properly supporting 64-bit systems.
    141138
    142139
    143 .. cfunction:: int PyList_Append(PyObject *list, PyObject *item)
     140.. c:function:: int PyList_Append(PyObject *list, PyObject *item)
    144141
    145142   Append the object *item* at the end of list *list*. Return ``0`` if
     
    148145
    149146
    150 .. cfunction:: PyObject* PyList_GetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high)
     147.. c:function:: PyObject* PyList_GetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high)
    151148
    152149   Return a list of the objects in *list* containing the objects *between* *low*
     
    156153
    157154   .. versionchanged:: 2.5
    158       This function used an :ctype:`int` for *low* and *high*. This might
     155      This function used an :c:type:`int` for *low* and *high*. This might
    159156      require changes in your code for properly supporting 64-bit systems.
    160157
    161158
    162 .. cfunction:: int PyList_SetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high, PyObject *itemlist)
     159.. c:function:: int PyList_SetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high, PyObject *itemlist)
    163160
    164161   Set the slice of *list* between *low* and *high* to the contents of
     
    169166
    170167   .. versionchanged:: 2.5
    171       This function used an :ctype:`int` for *low* and *high*. This might
     168      This function used an :c:type:`int` for *low* and *high*. This might
    172169      require changes in your code for properly supporting 64-bit systems.
    173170
    174171
    175 .. cfunction:: int PyList_Sort(PyObject *list)
     172.. c:function:: int PyList_Sort(PyObject *list)
    176173
    177174   Sort the items of *list* in place.  Return ``0`` on success, ``-1`` on
     
    179176
    180177
    181 .. cfunction:: int PyList_Reverse(PyObject *list)
     178.. c:function:: int PyList_Reverse(PyObject *list)
    182179
    183180   Reverse the items of *list* in place.  Return ``0`` on success, ``-1`` on
     
    185182
    186183
    187 .. cfunction:: PyObject* PyList_AsTuple(PyObject *list)
     184.. c:function:: PyObject* PyList_AsTuple(PyObject *list)
    188185
    189186   .. index:: builtin: tuple
  • python/vendor/current/Doc/c-api/long.rst

    r2 r388  
    99
    1010
    11 .. ctype:: PyLongObject
    12 
    13    This subtype of :ctype:`PyObject` represents a Python long integer object.
    14 
    15 
    16 .. cvar:: PyTypeObject PyLong_Type
     11.. c:type:: PyLongObject
     12
     13   This subtype of :c:type:`PyObject` represents a Python long integer object.
     14
     15
     16.. c:var:: PyTypeObject PyLong_Type
    1717
    1818   .. index:: single: LongType (in modules types)
    1919
    20    This instance of :ctype:`PyTypeObject` represents the Python long integer type.
     20   This instance of :c:type:`PyTypeObject` represents the Python long integer type.
    2121   This is the same object as ``long`` and ``types.LongType``.
    2222
    2323
    24 .. cfunction:: int PyLong_Check(PyObject *p)
    25 
    26    Return true if its argument is a :ctype:`PyLongObject` or a subtype of
    27    :ctype:`PyLongObject`.
     24.. c:function:: int PyLong_Check(PyObject *p)
     25
     26   Return true if its argument is a :c:type:`PyLongObject` or a subtype of
     27   :c:type:`PyLongObject`.
    2828
    2929   .. versionchanged:: 2.2
     
    3131
    3232
    33 .. cfunction:: int PyLong_CheckExact(PyObject *p)
    34 
    35    Return true if its argument is a :ctype:`PyLongObject`, but not a subtype of
    36    :ctype:`PyLongObject`.
     33.. c:function:: int PyLong_CheckExact(PyObject *p)
     34
     35   Return true if its argument is a :c:type:`PyLongObject`, but not a subtype of
     36   :c:type:`PyLongObject`.
    3737
    3838   .. versionadded:: 2.2
    3939
    4040
    41 .. cfunction:: PyObject* PyLong_FromLong(long v)
    42 
    43    Return a new :ctype:`PyLongObject` object from *v*, or *NULL* on failure.
    44 
    45 
    46 .. cfunction:: PyObject* PyLong_FromUnsignedLong(unsigned long v)
    47 
    48    Return a new :ctype:`PyLongObject` object from a C :ctype:`unsigned long`, or
    49    *NULL* on failure.
    50 
    51 
    52 .. cfunction:: PyObject* PyLong_FromSsize_t(Py_ssize_t v)
    53 
    54    Return a new :ctype:`PyLongObject` object from a C :ctype:`Py_ssize_t`, or
    55    *NULL* on failure.
    56 
    57    .. versionadded:: 2.6
    58 
    59 
    60 .. cfunction:: PyObject* PyLong_FromSize_t(size_t v)
    61 
    62    Return a new :ctype:`PyLongObject` object from a C :ctype:`size_t`, or
    63    *NULL* on failure.
    64 
    65    .. versionadded:: 2.6
    66 
    67 
    68 .. cfunction:: PyObject* PyLong_FromLongLong(PY_LONG_LONG v)
    69 
    70    Return a new :ctype:`PyLongObject` object from a C :ctype:`long long`, or *NULL*
     41.. c:function:: PyObject* PyLong_FromLong(long v)
     42
     43   Return a new :c:type:`PyLongObject` object from *v*, or *NULL* on failure.
     44
     45
     46.. c:function:: PyObject* PyLong_FromUnsignedLong(unsigned long v)
     47
     48   Return a new :c:type:`PyLongObject` object from a C :c:type:`unsigned long`, or
     49   *NULL* on failure.
     50
     51
     52.. c:function:: PyObject* PyLong_FromSsize_t(Py_ssize_t v)
     53
     54   Return a new :c:type:`PyLongObject` object from a C :c:type:`Py_ssize_t`, or
     55   *NULL* on failure.
     56
     57   .. versionadded:: 2.6
     58
     59
     60.. c:function:: PyObject* PyLong_FromSize_t(size_t v)
     61
     62   Return a new :c:type:`PyLongObject` object from a C :c:type:`size_t`, or
     63   *NULL* on failure.
     64
     65   .. versionadded:: 2.6
     66
     67
     68.. c:function:: PyObject* PyLong_FromSsize_t(Py_ssize_t v)
     69
     70   Return a new :c:type:`PyLongObject` object with a value of *v*, or *NULL*
    7171   on failure.
    7272
    73 
    74 .. cfunction:: PyObject* PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG v)
    75 
    76    Return a new :ctype:`PyLongObject` object from a C :ctype:`unsigned long long`,
     73   .. versionadded:: 2.6
     74
     75
     76.. c:function:: PyObject* PyLong_FromSize_t(size_t v)
     77
     78   Return a new :c:type:`PyLongObject` object with a value of *v*, or *NULL*
     79   on failure.
     80
     81   .. versionadded:: 2.6
     82
     83
     84.. c:function:: PyObject* PyLong_FromLongLong(PY_LONG_LONG v)
     85
     86   Return a new :c:type:`PyLongObject` object from a C :c:type:`long long`, or *NULL*
     87   on failure.
     88
     89
     90.. c:function:: PyObject* PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG v)
     91
     92   Return a new :c:type:`PyLongObject` object from a C :c:type:`unsigned long long`,
    7793   or *NULL* on failure.
    7894
    7995
    80 .. cfunction:: PyObject* PyLong_FromDouble(double v)
    81 
    82    Return a new :ctype:`PyLongObject` object from the integer part of *v*, or
    83    *NULL* on failure.
    84 
    85 
    86 .. cfunction:: PyObject* PyLong_FromString(char *str, char **pend, int base)
    87 
    88    Return a new :ctype:`PyLongObject` based on the string value in *str*, which is
     96.. c:function:: PyObject* PyLong_FromDouble(double v)
     97
     98   Return a new :c:type:`PyLongObject` object from the integer part of *v*, or
     99   *NULL* on failure.
     100
     101
     102.. c:function:: PyObject* PyLong_FromString(char *str, char **pend, int base)
     103
     104   Return a new :c:type:`PyLongObject` based on the string value in *str*, which is
    89105   interpreted according to the radix in *base*.  If *pend* is non-*NULL*,
    90    ``*pend`` will point to the first character in *str* which follows the
     106   *\*pend* will point to the first character in *str* which follows the
    91107   representation of the number.  If *base* is ``0``, the radix will be determined
    92108   based on the leading characters of *str*: if *str* starts with ``'0x'`` or
     
    97113
    98114
    99 .. cfunction:: PyObject* PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base)
     115.. c:function:: PyObject* PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base)
    100116
    101117   Convert a sequence of Unicode digits to a Python long integer value.  The first
     
    108124
    109125   .. versionchanged:: 2.5
    110       This function used an :ctype:`int` for *length*. This might require
     126      This function used an :c:type:`int` for *length*. This might require
    111127      changes in your code for properly supporting 64-bit systems.
    112128
    113129
    114 .. cfunction:: PyObject* PyLong_FromVoidPtr(void *p)
     130.. c:function:: PyObject* PyLong_FromVoidPtr(void *p)
    115131
    116132   Create a Python integer or long integer from the pointer *p*. The pointer value
    117    can be retrieved from the resulting value using :cfunc:`PyLong_AsVoidPtr`.
     133   can be retrieved from the resulting value using :c:func:`PyLong_AsVoidPtr`.
    118134
    119135   .. versionadded:: 1.5.2
     
    123139
    124140
    125 .. cfunction:: long PyLong_AsLong(PyObject *pylong)
     141.. c:function:: long PyLong_AsLong(PyObject *pylong)
    126142
    127143   .. index::
     
    129145      single: OverflowError (built-in exception)
    130146
    131    Return a C :ctype:`long` representation of the contents of *pylong*.  If
     147   Return a C :c:type:`long` representation of the contents of *pylong*.  If
    132148   *pylong* is greater than :const:`LONG_MAX`, an :exc:`OverflowError` is raised
    133149   and ``-1`` will be returned.
    134150
    135151
    136 .. cfunction:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)
     152.. c:function:: long PyLong_AsLongAndOverflow(PyObject *pylong, int *overflow)
     153
     154   Return a C :c:type:`long` representation of the contents of
     155   *pylong*.  If *pylong* is greater than :const:`LONG_MAX` or less
     156   than :const:`LONG_MIN`, set *\*overflow* to ``1`` or ``-1``,
     157   respectively, and return ``-1``; otherwise, set *\*overflow* to
     158   ``0``.  If any other exception occurs (for example a TypeError or
     159   MemoryError), then ``-1`` will be returned and *\*overflow* will
     160   be ``0``.
     161
     162   .. versionadded:: 2.7
     163
     164
     165.. c:function:: PY_LONG_LONG PyLong_AsLongLongAndOverflow(PyObject *pylong, int *overflow)
     166
     167   Return a C :c:type:`long long` representation of the contents of
     168   *pylong*.  If *pylong* is greater than :const:`PY_LLONG_MAX` or less
     169   than :const:`PY_LLONG_MIN`, set *\*overflow* to ``1`` or ``-1``,
     170   respectively, and return ``-1``; otherwise, set *\*overflow* to
     171   ``0``.  If any other exception occurs (for example a TypeError or
     172   MemoryError), then ``-1`` will be returned and *\*overflow* will
     173   be ``0``.
     174
     175   .. versionadded:: 2.7
     176
     177
     178.. c:function:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)
    137179
    138180   .. index::
     
    140182      single: OverflowError (built-in exception)
    141183
    142    Return a C :ctype:`Py_ssize_t` representation of the contents of *pylong*.  If
     184   Return a C :c:type:`Py_ssize_t` representation of the contents of *pylong*.  If
    143185   *pylong* is greater than :const:`PY_SSIZE_T_MAX`, an :exc:`OverflowError` is raised
    144186   and ``-1`` will be returned.
     
    147189
    148190
    149 .. cfunction:: unsigned long PyLong_AsUnsignedLong(PyObject *pylong)
     191.. c:function:: unsigned long PyLong_AsUnsignedLong(PyObject *pylong)
    150192
    151193   .. index::
     
    153195      single: OverflowError (built-in exception)
    154196
    155    Return a C :ctype:`unsigned long` representation of the contents of *pylong*.
     197   Return a C :c:type:`unsigned long` representation of the contents of *pylong*.
    156198   If *pylong* is greater than :const:`ULONG_MAX`, an :exc:`OverflowError` is
    157199   raised.
    158200
    159201
    160 .. cfunction:: PY_LONG_LONG PyLong_AsLongLong(PyObject *pylong)
    161 
    162    Return a C :ctype:`long long` from a Python long integer.  If *pylong* cannot be
    163    represented as a :ctype:`long long`, an :exc:`OverflowError` will be raised.
     202.. c:function:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)
     203
     204   .. index::
     205      single: PY_SSIZE_T_MAX
     206
     207   Return a :c:type:`Py_ssize_t` representation of the contents of *pylong*.  If
     208   *pylong* is greater than :const:`PY_SSIZE_T_MAX`, an :exc:`OverflowError` is
     209   raised.
     210
     211   .. versionadded:: 2.6
     212
     213
     214.. c:function:: PY_LONG_LONG PyLong_AsLongLong(PyObject *pylong)
     215
     216   .. index::
     217      single: OverflowError (built-in exception)
     218
     219   Return a C :c:type:`long long` from a Python long integer.  If
     220   *pylong* cannot be represented as a :c:type:`long long`, an
     221   :exc:`OverflowError` is raised and ``-1`` is returned.
    164222
    165223   .. versionadded:: 2.2
    166224
    167225
    168 .. cfunction:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong)
    169 
    170    Return a C :ctype:`unsigned long long` from a Python long integer. If *pylong*
    171    cannot be represented as an :ctype:`unsigned long long`, an :exc:`OverflowError`
    172    will be raised if the value is positive, or a :exc:`TypeError` will be raised if
    173    the value is negative.
     226.. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong)
     227
     228   .. index::
     229      single: OverflowError (built-in exception)
     230
     231   Return a C :c:type:`unsigned long long` from a Python long integer. If
     232   *pylong* cannot be represented as an :c:type:`unsigned long long`, an
     233   :exc:`OverflowError` is raised and ``(unsigned long long)-1`` is
     234   returned.
    174235
    175236   .. versionadded:: 2.2
    176237
    177 
    178 .. cfunction:: unsigned long PyLong_AsUnsignedLongMask(PyObject *io)
    179 
    180    Return a C :ctype:`unsigned long` from a Python long integer, without checking
     238   .. versionchanged:: 2.7
     239      A negative *pylong* now raises :exc:`OverflowError`, not
     240      :exc:`TypeError`.
     241
     242
     243.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *io)
     244
     245   Return a C :c:type:`unsigned long` from a Python long integer, without checking
    181246   for overflow.
    182247
     
    184249
    185250
    186 .. cfunction:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *io)
    187 
    188    Return a C :ctype:`unsigned long long` from a Python long integer, without
     251.. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *io)
     252
     253   Return a C :c:type:`unsigned long long` from a Python long integer, without
    189254   checking for overflow.
    190255
     
    192257
    193258
    194 .. cfunction:: double PyLong_AsDouble(PyObject *pylong)
    195 
    196    Return a C :ctype:`double` representation of the contents of *pylong*.  If
    197    *pylong* cannot be approximately represented as a :ctype:`double`, an
     259.. c:function:: double PyLong_AsDouble(PyObject *pylong)
     260
     261   Return a C :c:type:`double` representation of the contents of *pylong*.  If
     262   *pylong* cannot be approximately represented as a :c:type:`double`, an
    198263   :exc:`OverflowError` exception is raised and ``-1.0`` will be returned.
    199264
    200265
    201 .. cfunction:: void* PyLong_AsVoidPtr(PyObject *pylong)
    202 
    203    Convert a Python integer or long integer *pylong* to a C :ctype:`void` pointer.
     266.. c:function:: void* PyLong_AsVoidPtr(PyObject *pylong)
     267
     268   Convert a Python integer or long integer *pylong* to a C :c:type:`void` pointer.
    204269   If *pylong* cannot be converted, an :exc:`OverflowError` will be raised.  This
    205    is only assured to produce a usable :ctype:`void` pointer for values created
    206    with :cfunc:`PyLong_FromVoidPtr`.
     270   is only assured to produce a usable :c:type:`void` pointer for values created
     271   with :c:func:`PyLong_FromVoidPtr`.
    207272
    208273   .. versionadded:: 1.5.2
  • python/vendor/current/Doc/c-api/mapping.rst

    r2 r388  
    77
    88
    9 .. cfunction:: int PyMapping_Check(PyObject *o)
     9.. c:function:: int PyMapping_Check(PyObject *o)
    1010
    1111   Return ``1`` if the object provides mapping protocol, and ``0`` otherwise.  This
     
    1313
    1414
    15 .. cfunction:: Py_ssize_t PyMapping_Size(PyObject *o)
     15.. c:function:: Py_ssize_t PyMapping_Size(PyObject *o)
    1616               Py_ssize_t PyMapping_Length(PyObject *o)
    1717
     
    2323
    2424   .. versionchanged:: 2.5
    25       These functions returned an :ctype:`int` type. This might require
     25      These functions returned an :c:type:`int` type. This might require
    2626      changes in your code for properly supporting 64-bit systems.
    2727
    2828
    29 .. cfunction:: int PyMapping_DelItemString(PyObject *o, char *key)
     29.. c:function:: int PyMapping_DelItemString(PyObject *o, char *key)
    3030
    3131   Remove the mapping for object *key* from the object *o*. Return ``-1`` on
     
    3333
    3434
    35 .. cfunction:: int PyMapping_DelItem(PyObject *o, PyObject *key)
     35.. c:function:: int PyMapping_DelItem(PyObject *o, PyObject *key)
    3636
    3737   Remove the mapping for object *key* from the object *o*. Return ``-1`` on
     
    3939
    4040
    41 .. cfunction:: int PyMapping_HasKeyString(PyObject *o, char *key)
     41.. c:function:: int PyMapping_HasKeyString(PyObject *o, char *key)
    4242
    4343   On success, return ``1`` if the mapping object has the key *key* and ``0``
     
    4646
    4747
    48 .. cfunction:: int PyMapping_HasKey(PyObject *o, PyObject *key)
     48.. c:function:: int PyMapping_HasKey(PyObject *o, PyObject *key)
    4949
    5050   Return ``1`` if the mapping object has the key *key* and ``0`` otherwise.
     
    5353
    5454
    55 .. cfunction:: PyObject* PyMapping_Keys(PyObject *o)
     55.. c:function:: PyObject* PyMapping_Keys(PyObject *o)
    5656
    5757   On success, return a list of the keys in object *o*.  On failure, return *NULL*.
     
    5959
    6060
    61 .. cfunction:: PyObject* PyMapping_Values(PyObject *o)
     61.. c:function:: PyObject* PyMapping_Values(PyObject *o)
    6262
    6363   On success, return a list of the values in object *o*.  On failure, return
     
    6565
    6666
    67 .. cfunction:: PyObject* PyMapping_Items(PyObject *o)
     67.. c:function:: PyObject* PyMapping_Items(PyObject *o)
    6868
    6969   On success, return a list of the items in object *o*, where each item is a tuple
     
    7272
    7373
    74 .. cfunction:: PyObject* PyMapping_GetItemString(PyObject *o, char *key)
     74.. c:function:: PyObject* PyMapping_GetItemString(PyObject *o, char *key)
    7575
    7676   Return element of *o* corresponding to the object *key* or *NULL* on failure.
     
    7878
    7979
    80 .. cfunction:: int PyMapping_SetItemString(PyObject *o, char *key, PyObject *v)
     80.. c:function:: int PyMapping_SetItemString(PyObject *o, char *key, PyObject *v)
    8181
    8282   Map the object *key* to the value *v* in object *o*. Returns ``-1`` on failure.
  • python/vendor/current/Doc/c-api/marshal.rst

    r2 r388  
    2121
    2222
    23 .. cfunction:: void PyMarshal_WriteLongToFile(long value, FILE *file, int version)
     23.. c:function:: void PyMarshal_WriteLongToFile(long value, FILE *file, int version)
    2424
    25    Marshal a :ctype:`long` integer, *value*, to *file*.  This will only write
     25   Marshal a :c:type:`long` integer, *value*, to *file*.  This will only write
    2626   the least-significant 32 bits of *value*; regardless of the size of the
    27    native :ctype:`long` type.
     27   native :c:type:`long` type.
    2828
    2929   .. versionchanged:: 2.4
     
    3131
    3232
    33 .. cfunction:: void PyMarshal_WriteObjectToFile(PyObject *value, FILE *file, int version)
     33.. c:function:: void PyMarshal_WriteObjectToFile(PyObject *value, FILE *file, int version)
    3434
    3535   Marshal a Python object, *value*, to *file*.
     
    3939
    4040
    41 .. cfunction:: PyObject* PyMarshal_WriteObjectToString(PyObject *value, int version)
     41.. c:function:: PyObject* PyMarshal_WriteObjectToString(PyObject *value, int version)
    4242
    4343   Return a string object containing the marshalled representation of *value*.
     
    5656
    5757
    58 .. cfunction:: long PyMarshal_ReadLongFromFile(FILE *file)
     58.. c:function:: long PyMarshal_ReadLongFromFile(FILE *file)
    5959
    60    Return a C :ctype:`long` from the data stream in a :ctype:`FILE\*` opened
     60   Return a C :c:type:`long` from the data stream in a :c:type:`FILE\*` opened
    6161   for reading.  Only a 32-bit value can be read in using this function,
    62    regardless of the native size of :ctype:`long`.
     62   regardless of the native size of :c:type:`long`.
    6363
    6464
    65 .. cfunction:: int PyMarshal_ReadShortFromFile(FILE *file)
     65.. c:function:: int PyMarshal_ReadShortFromFile(FILE *file)
    6666
    67    Return a C :ctype:`short` from the data stream in a :ctype:`FILE\*` opened
     67   Return a C :c:type:`short` from the data stream in a :c:type:`FILE\*` opened
    6868   for reading.  Only a 16-bit value can be read in using this function,
    69    regardless of the native size of :ctype:`short`.
     69   regardless of the native size of :c:type:`short`.
    7070
    7171
    72 .. cfunction:: PyObject* PyMarshal_ReadObjectFromFile(FILE *file)
     72.. c:function:: PyObject* PyMarshal_ReadObjectFromFile(FILE *file)
    7373
    74    Return a Python object from the data stream in a :ctype:`FILE\*` opened for
     74   Return a Python object from the data stream in a :c:type:`FILE\*` opened for
    7575   reading.  On error, sets the appropriate exception (:exc:`EOFError` or
    7676   :exc:`TypeError`) and returns *NULL*.
    7777
    7878
    79 .. cfunction:: PyObject* PyMarshal_ReadLastObjectFromFile(FILE *file)
     79.. c:function:: PyObject* PyMarshal_ReadLastObjectFromFile(FILE *file)
    8080
    81    Return a Python object from the data stream in a :ctype:`FILE\*` opened for
    82    reading.  Unlike :cfunc:`PyMarshal_ReadObjectFromFile`, this function
     81   Return a Python object from the data stream in a :c:type:`FILE\*` opened for
     82   reading.  Unlike :c:func:`PyMarshal_ReadObjectFromFile`, this function
    8383   assumes that no further objects will be read from the file, allowing it to
    8484   aggressively load file data into memory so that the de-serialization can
     
    8989
    9090
    91 .. cfunction:: PyObject* PyMarshal_ReadObjectFromString(char *string, Py_ssize_t len)
     91.. c:function:: PyObject* PyMarshal_ReadObjectFromString(char *string, Py_ssize_t len)
    9292
    9393   Return a Python object from the data stream in a character buffer
     
    9797
    9898   .. versionchanged:: 2.5
    99       This function used an :ctype:`int` type for *len*. This might require
     99      This function used an :c:type:`int` type for *len*. This might require
    100100      changes in your code for properly supporting 64-bit systems.
  • python/vendor/current/Doc/c-api/memory.rst

    r2 r388  
    4848
    4949To avoid memory corruption, extension writers should never try to operate on
    50 Python objects with the functions exported by the C library: :cfunc:`malloc`,
    51 :cfunc:`calloc`, :cfunc:`realloc` and :cfunc:`free`.  This will result in  mixed
     50Python objects with the functions exported by the C library: :c:func:`malloc`,
     51:c:func:`calloc`, :c:func:`realloc` and :c:func:`free`.  This will result in  mixed
    5252calls between the C allocator and the Python memory manager with fatal
    5353consequences, because they implement different algorithms and operate on
     
    9595
    9696
    97 .. cfunction:: void* PyMem_Malloc(size_t n)
    98 
    99    Allocates *n* bytes and returns a pointer of type :ctype:`void\*` to the
     97.. c:function:: void* PyMem_Malloc(size_t n)
     98
     99   Allocates *n* bytes and returns a pointer of type :c:type:`void\*` to the
    100100   allocated memory, or *NULL* if the request fails. Requesting zero bytes returns
    101    a distinct non-*NULL* pointer if possible, as if :cfunc:`PyMem_Malloc(1)` had
     101   a distinct non-*NULL* pointer if possible, as if ``PyMem_Malloc(1)`` had
    102102   been called instead. The memory will not have been initialized in any way.
    103103
    104104
    105 .. cfunction:: void* PyMem_Realloc(void *p, size_t n)
     105.. c:function:: void* PyMem_Realloc(void *p, size_t n)
    106106
    107107   Resizes the memory block pointed to by *p* to *n* bytes. The contents will be
    108108   unchanged to the minimum of the old and the new sizes. If *p* is *NULL*, the
    109    call is equivalent to :cfunc:`PyMem_Malloc(n)`; else if *n* is equal to zero,
     109   call is equivalent to ``PyMem_Malloc(n)``; else if *n* is equal to zero,
    110110   the memory block is resized but is not freed, and the returned pointer is
    111111   non-*NULL*.  Unless *p* is *NULL*, it must have been returned by a previous call
    112    to :cfunc:`PyMem_Malloc` or :cfunc:`PyMem_Realloc`. If the request fails,
    113    :cfunc:`PyMem_Realloc` returns *NULL* and *p* remains a valid pointer to the
     112   to :c:func:`PyMem_Malloc` or :c:func:`PyMem_Realloc`. If the request fails,
     113   :c:func:`PyMem_Realloc` returns *NULL* and *p* remains a valid pointer to the
    114114   previous memory area.
    115115
    116116
    117 .. cfunction:: void PyMem_Free(void *p)
     117.. c:function:: void PyMem_Free(void *p)
    118118
    119119   Frees the memory block pointed to by *p*, which must have been returned by a
    120    previous call to :cfunc:`PyMem_Malloc` or :cfunc:`PyMem_Realloc`.  Otherwise, or
    121    if :cfunc:`PyMem_Free(p)` has been called before, undefined behavior occurs. If
     120   previous call to :c:func:`PyMem_Malloc` or :c:func:`PyMem_Realloc`.  Otherwise, or
     121   if ``PyMem_Free(p)`` has been called before, undefined behavior occurs. If
    122122   *p* is *NULL*, no operation is performed.
    123123
     
    126126
    127127
    128 .. cfunction:: TYPE* PyMem_New(TYPE, size_t n)
    129 
    130    Same as :cfunc:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes of
    131    memory.  Returns a pointer cast to :ctype:`TYPE\*`.  The memory will not have
     128.. c:function:: TYPE* PyMem_New(TYPE, size_t n)
     129
     130   Same as :c:func:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes of
     131   memory.  Returns a pointer cast to :c:type:`TYPE\*`.  The memory will not have
    132132   been initialized in any way.
    133133
    134134
    135 .. cfunction:: TYPE* PyMem_Resize(void *p, TYPE, size_t n)
    136 
    137    Same as :cfunc:`PyMem_Realloc`, but the memory block is resized to ``(n *
    138    sizeof(TYPE))`` bytes.  Returns a pointer cast to :ctype:`TYPE\*`. On return,
     135.. c:function:: TYPE* PyMem_Resize(void *p, TYPE, size_t n)
     136
     137   Same as :c:func:`PyMem_Realloc`, but the memory block is resized to ``(n *
     138   sizeof(TYPE))`` bytes.  Returns a pointer cast to :c:type:`TYPE\*`. On return,
    139139   *p* will be a pointer to the new memory area, or *NULL* in the event of
    140140   failure.  This is a C preprocessor macro; p is always reassigned.  Save
     
    142142
    143143
    144 .. cfunction:: void PyMem_Del(void *p)
    145 
    146    Same as :cfunc:`PyMem_Free`.
     144.. c:function:: void PyMem_Del(void *p)
     145
     146   Same as :c:func:`PyMem_Free`.
    147147
    148148In addition, the following macro sets are provided for calling the Python memory
     
    151151versions and is therefore deprecated in extension modules.
    152152
    153 :cfunc:`PyMem_MALLOC`, :cfunc:`PyMem_REALLOC`, :cfunc:`PyMem_FREE`.
    154 
    155 :cfunc:`PyMem_NEW`, :cfunc:`PyMem_RESIZE`, :cfunc:`PyMem_DEL`.
     153:c:func:`PyMem_MALLOC`, :c:func:`PyMem_REALLOC`, :c:func:`PyMem_FREE`.
     154
     155:c:func:`PyMem_NEW`, :c:func:`PyMem_RESIZE`, :c:func:`PyMem_DEL`.
    156156
    157157
     
    202202
    203203In addition to the functions aimed at handling raw memory blocks from the Python
    204 heap, objects in Python are allocated and released with :cfunc:`PyObject_New`,
    205 :cfunc:`PyObject_NewVar` and :cfunc:`PyObject_Del`.
     204heap, objects in Python are allocated and released with :c:func:`PyObject_New`,
     205:c:func:`PyObject_NewVar` and :c:func:`PyObject_Del`.
    206206
    207207These will be explained in the next chapter on defining and implementing new
  • python/vendor/current/Doc/c-api/method.rst

    r2 r388  
    1111
    1212
    13 .. cvar:: PyTypeObject PyMethod_Type
     13.. c:var:: PyTypeObject PyMethod_Type
    1414
    1515   .. index:: single: MethodType (in module types)
    1616
    17    This instance of :ctype:`PyTypeObject` represents the Python method type.  This
     17   This instance of :c:type:`PyTypeObject` represents the Python method type.  This
    1818   is exposed to Python programs as ``types.MethodType``.
    1919
    2020
    21 .. cfunction:: int PyMethod_Check(PyObject *o)
     21.. c:function:: int PyMethod_Check(PyObject *o)
    2222
    23    Return true if *o* is a method object (has type :cdata:`PyMethod_Type`).  The
     23   Return true if *o* is a method object (has type :c:data:`PyMethod_Type`).  The
    2424   parameter must not be *NULL*.
    2525
    2626
    27 .. cfunction:: PyObject* PyMethod_New(PyObject *func, PyObject *self, PyObject *class)
     27.. c:function:: PyObject* PyMethod_New(PyObject *func, PyObject *self, PyObject *class)
    2828
    2929   Return a new method object, with *func* being any callable object; this is the
     
    3434
    3535
    36 .. cfunction:: PyObject* PyMethod_Class(PyObject *meth)
     36.. c:function:: PyObject* PyMethod_Class(PyObject *meth)
    3737
    3838   Return the class object from which the method *meth* was created; if this was
     
    4040
    4141
    42 .. cfunction:: PyObject* PyMethod_GET_CLASS(PyObject *meth)
     42.. c:function:: PyObject* PyMethod_GET_CLASS(PyObject *meth)
    4343
    44    Macro version of :cfunc:`PyMethod_Class` which avoids error checking.
     44   Macro version of :c:func:`PyMethod_Class` which avoids error checking.
    4545
    4646
    47 .. cfunction:: PyObject* PyMethod_Function(PyObject *meth)
     47.. c:function:: PyObject* PyMethod_Function(PyObject *meth)
    4848
    4949   Return the function object associated with the method *meth*.
    5050
    5151
    52 .. cfunction:: PyObject* PyMethod_GET_FUNCTION(PyObject *meth)
     52.. c:function:: PyObject* PyMethod_GET_FUNCTION(PyObject *meth)
    5353
    54    Macro version of :cfunc:`PyMethod_Function` which avoids error checking.
     54   Macro version of :c:func:`PyMethod_Function` which avoids error checking.
    5555
    5656
    57 .. cfunction:: PyObject* PyMethod_Self(PyObject *meth)
     57.. c:function:: PyObject* PyMethod_Self(PyObject *meth)
    5858
    5959   Return the instance associated with the method *meth* if it is bound, otherwise
     
    6161
    6262
    63 .. cfunction:: PyObject* PyMethod_GET_SELF(PyObject *meth)
     63.. c:function:: PyObject* PyMethod_GET_SELF(PyObject *meth)
    6464
    65    Macro version of :cfunc:`PyMethod_Self` which avoids error checking.
     65   Macro version of :c:func:`PyMethod_Self` which avoids error checking.
    6666
    6767
    68 .. cfunction:: int PyMethod_ClearFreeList()
     68.. c:function:: int PyMethod_ClearFreeList()
    6969
    7070   Clear the free list. Return the total number of freed items.
  • python/vendor/current/Doc/c-api/module.rst

    r2 r388  
    1111
    1212
    13 .. cvar:: PyTypeObject PyModule_Type
     13.. c:var:: PyTypeObject PyModule_Type
    1414
    1515   .. index:: single: ModuleType (in module types)
    1616
    17    This instance of :ctype:`PyTypeObject` represents the Python module type.  This
     17   This instance of :c:type:`PyTypeObject` represents the Python module type.  This
    1818   is exposed to Python programs as ``types.ModuleType``.
    1919
    2020
    21 .. cfunction:: int PyModule_Check(PyObject *p)
     21.. c:function:: int PyModule_Check(PyObject *p)
    2222
    2323   Return true if *p* is a module object, or a subtype of a module object.
     
    2727
    2828
    29 .. cfunction:: int PyModule_CheckExact(PyObject *p)
     29.. c:function:: int PyModule_CheckExact(PyObject *p)
    3030
    3131   Return true if *p* is a module object, but not a subtype of
    32    :cdata:`PyModule_Type`.
     32   :c:data:`PyModule_Type`.
    3333
    3434   .. versionadded:: 2.2
    3535
    3636
    37 .. cfunction:: PyObject* PyModule_New(const char *name)
     37.. c:function:: PyObject* PyModule_New(const char *name)
    3838
    3939   .. index::
     
    4747
    4848
    49 .. cfunction:: PyObject* PyModule_GetDict(PyObject *module)
     49.. c:function:: PyObject* PyModule_GetDict(PyObject *module)
    5050
    5151   .. index:: single: __dict__ (module attribute)
     
    5454   is the same as the :attr:`__dict__` attribute of the module object.  This
    5555   function never fails.  It is recommended extensions use other
    56    :cfunc:`PyModule_\*` and :cfunc:`PyObject_\*` functions rather than directly
     56   :c:func:`PyModule_\*` and :c:func:`PyObject_\*` functions rather than directly
    5757   manipulate a module's :attr:`__dict__`.
    5858
    5959
    60 .. cfunction:: char* PyModule_GetName(PyObject *module)
     60.. c:function:: char* PyModule_GetName(PyObject *module)
    6161
    6262   .. index::
     
    6868
    6969
    70 .. cfunction:: char* PyModule_GetFilename(PyObject *module)
     70.. c:function:: char* PyModule_GetFilename(PyObject *module)
    7171
    7272   .. index::
     
    7979
    8080
    81 .. cfunction:: int PyModule_AddObject(PyObject *module, const char *name, PyObject *value)
     81.. c:function:: int PyModule_AddObject(PyObject *module, const char *name, PyObject *value)
    8282
    8383   Add an object to *module* as *name*.  This is a convenience function which can
     
    8888
    8989
    90 .. cfunction:: int PyModule_AddIntConstant(PyObject *module, const char *name, long value)
     90.. c:function:: int PyModule_AddIntConstant(PyObject *module, const char *name, long value)
    9191
    9292   Add an integer constant to *module* as *name*.  This convenience function can be
     
    9797
    9898
    99 .. cfunction:: int PyModule_AddStringConstant(PyObject *module, const char *name, const char *value)
     99.. c:function:: int PyModule_AddStringConstant(PyObject *module, const char *name, const char *value)
    100100
    101101   Add a string constant to *module* as *name*.  This convenience function can be
     
    105105   .. versionadded:: 2.0
    106106
    107 .. cfunction:: int PyModule_AddIntMacro(PyObject *module, macro)
     107.. c:function:: int PyModule_AddIntMacro(PyObject *module, macro)
    108108
    109109   Add an int constant to *module*. The name and the value are taken from
    110    *macro*. For example ``PyModule_AddConstant(module, AF_INET)`` adds the int
     110   *macro*. For example ``PyModule_AddIntMacro(module, AF_INET)`` adds the int
    111111   constant *AF_INET* with the value of *AF_INET* to *module*.
    112112   Return ``-1`` on error, ``0`` on success.
     
    114114   .. versionadded:: 2.6
    115115
    116 .. cfunction:: int PyModule_AddStringMacro(PyObject *module, macro)
     116.. c:function:: int PyModule_AddStringMacro(PyObject *module, macro)
    117117
    118118   Add a string constant to *module*.
  • python/vendor/current/Doc/c-api/none.rst

    r2 r388  
    88.. index:: object: None
    99
    10 Note that the :ctype:`PyTypeObject` for ``None`` is not directly exposed in the
     10Note that the :c:type:`PyTypeObject` for ``None`` is not directly exposed in the
    1111Python/C API.  Since ``None`` is a singleton, testing for object identity (using
    12 ``==`` in C) is sufficient. There is no :cfunc:`PyNone_Check` function for the
     12``==`` in C) is sufficient. There is no :c:func:`PyNone_Check` function for the
    1313same reason.
    1414
    1515
    16 .. cvar:: PyObject* Py_None
     16.. c:var:: PyObject* Py_None
    1717
    1818   The Python ``None`` object, denoting lack of value.  This object has no methods.
     
    2121
    2222
    23 .. cmacro:: Py_RETURN_NONE
     23.. c:macro:: Py_RETURN_NONE
    2424
    25    Properly handle returning :cdata:`Py_None` from within a C function.
     25   Properly handle returning :c:data:`Py_None` from within a C function.
    2626
    2727   .. versionadded:: 2.4
  • python/vendor/current/Doc/c-api/number.rst

    r2 r388  
    77
    88
    9 .. cfunction:: int PyNumber_Check(PyObject *o)
     9.. c:function:: int PyNumber_Check(PyObject *o)
    1010
    1111   Returns ``1`` if the object *o* provides numeric protocols, and false otherwise.
     
    1313
    1414
    15 .. cfunction:: PyObject* PyNumber_Add(PyObject *o1, PyObject *o2)
     15.. c:function:: PyObject* PyNumber_Add(PyObject *o1, PyObject *o2)
    1616
    1717   Returns the result of adding *o1* and *o2*, or *NULL* on failure.  This is the
     
    1919
    2020
    21 .. cfunction:: PyObject* PyNumber_Subtract(PyObject *o1, PyObject *o2)
     21.. c:function:: PyObject* PyNumber_Subtract(PyObject *o1, PyObject *o2)
    2222
    2323   Returns the result of subtracting *o2* from *o1*, or *NULL* on failure.  This is
     
    2525
    2626
    27 .. cfunction:: PyObject* PyNumber_Multiply(PyObject *o1, PyObject *o2)
     27.. c:function:: PyObject* PyNumber_Multiply(PyObject *o1, PyObject *o2)
    2828
    2929   Returns the result of multiplying *o1* and *o2*, or *NULL* on failure.  This is
     
    3131
    3232
    33 .. cfunction:: PyObject* PyNumber_Divide(PyObject *o1, PyObject *o2)
     33.. c:function:: PyObject* PyNumber_Divide(PyObject *o1, PyObject *o2)
    3434
    3535   Returns the result of dividing *o1* by *o2*, or *NULL* on failure.  This is the
     
    3737
    3838
    39 .. cfunction:: PyObject* PyNumber_FloorDivide(PyObject *o1, PyObject *o2)
     39.. c:function:: PyObject* PyNumber_FloorDivide(PyObject *o1, PyObject *o2)
    4040
    4141   Return the floor of *o1* divided by *o2*, or *NULL* on failure.  This is
     
    4545
    4646
    47 .. cfunction:: PyObject* PyNumber_TrueDivide(PyObject *o1, PyObject *o2)
     47.. c:function:: PyObject* PyNumber_TrueDivide(PyObject *o1, PyObject *o2)
    4848
    4949   Return a reasonable approximation for the mathematical value of *o1* divided by
     
    5656
    5757
    58 .. cfunction:: PyObject* PyNumber_Remainder(PyObject *o1, PyObject *o2)
     58.. c:function:: PyObject* PyNumber_Remainder(PyObject *o1, PyObject *o2)
    5959
    6060   Returns the remainder of dividing *o1* by *o2*, or *NULL* on failure.  This is
     
    6262
    6363
    64 .. cfunction:: PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2)
     64.. c:function:: PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2)
    6565
    6666   .. index:: builtin: divmod
     
    7070
    7171
    72 .. cfunction:: PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3)
     72.. c:function:: PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3)
    7373
    7474   .. index:: builtin: pow
     
    7676   See the built-in function :func:`pow`. Returns *NULL* on failure.  This is the
    7777   equivalent of the Python expression ``pow(o1, o2, o3)``, where *o3* is optional.
    78    If *o3* is to be ignored, pass :cdata:`Py_None` in its place (passing *NULL* for
     78   If *o3* is to be ignored, pass :c:data:`Py_None` in its place (passing *NULL* for
    7979   *o3* would cause an illegal memory access).
    8080
    8181
    82 .. cfunction:: PyObject* PyNumber_Negative(PyObject *o)
     82.. c:function:: PyObject* PyNumber_Negative(PyObject *o)
    8383
    8484   Returns the negation of *o* on success, or *NULL* on failure. This is the
     
    8686
    8787
    88 .. cfunction:: PyObject* PyNumber_Positive(PyObject *o)
     88.. c:function:: PyObject* PyNumber_Positive(PyObject *o)
    8989
    9090   Returns *o* on success, or *NULL* on failure.  This is the equivalent of the
     
    9292
    9393
    94 .. cfunction:: PyObject* PyNumber_Absolute(PyObject *o)
     94.. c:function:: PyObject* PyNumber_Absolute(PyObject *o)
    9595
    9696   .. index:: builtin: abs
     
    100100
    101101
    102 .. cfunction:: PyObject* PyNumber_Invert(PyObject *o)
     102.. c:function:: PyObject* PyNumber_Invert(PyObject *o)
    103103
    104104   Returns the bitwise negation of *o* on success, or *NULL* on failure.  This is
     
    106106
    107107
    108 .. cfunction:: PyObject* PyNumber_Lshift(PyObject *o1, PyObject *o2)
     108.. c:function:: PyObject* PyNumber_Lshift(PyObject *o1, PyObject *o2)
    109109
    110110   Returns the result of left shifting *o1* by *o2* on success, or *NULL* on
     
    112112
    113113
    114 .. cfunction:: PyObject* PyNumber_Rshift(PyObject *o1, PyObject *o2)
     114.. c:function:: PyObject* PyNumber_Rshift(PyObject *o1, PyObject *o2)
    115115
    116116   Returns the result of right shifting *o1* by *o2* on success, or *NULL* on
     
    118118
    119119
    120 .. cfunction:: PyObject* PyNumber_And(PyObject *o1, PyObject *o2)
     120.. c:function:: PyObject* PyNumber_And(PyObject *o1, PyObject *o2)
    121121
    122122   Returns the "bitwise and" of *o1* and *o2* on success and *NULL* on failure.
     
    124124
    125125
    126 .. cfunction:: PyObject* PyNumber_Xor(PyObject *o1, PyObject *o2)
     126.. c:function:: PyObject* PyNumber_Xor(PyObject *o1, PyObject *o2)
    127127
    128128   Returns the "bitwise exclusive or" of *o1* by *o2* on success, or *NULL* on
     
    130130
    131131
    132 .. cfunction:: PyObject* PyNumber_Or(PyObject *o1, PyObject *o2)
     132.. c:function:: PyObject* PyNumber_Or(PyObject *o1, PyObject *o2)
    133133
    134134   Returns the "bitwise or" of *o1* and *o2* on success, or *NULL* on failure.
     
    136136
    137137
    138 .. cfunction:: PyObject* PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2)
     138.. c:function:: PyObject* PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2)
    139139
    140140   Returns the result of adding *o1* and *o2*, or *NULL* on failure.  The operation
     
    143143
    144144
    145 .. cfunction:: PyObject* PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2)
     145.. c:function:: PyObject* PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2)
    146146
    147147   Returns the result of subtracting *o2* from *o1*, or *NULL* on failure.  The
     
    150150
    151151
    152 .. cfunction:: PyObject* PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2)
     152.. c:function:: PyObject* PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2)
    153153
    154154   Returns the result of multiplying *o1* and *o2*, or *NULL* on failure.  The
     
    157157
    158158
    159 .. cfunction:: PyObject* PyNumber_InPlaceDivide(PyObject *o1, PyObject *o2)
     159.. c:function:: PyObject* PyNumber_InPlaceDivide(PyObject *o1, PyObject *o2)
    160160
    161161   Returns the result of dividing *o1* by *o2*, or *NULL* on failure.  The
     
    164164
    165165
    166 .. cfunction:: PyObject* PyNumber_InPlaceFloorDivide(PyObject *o1, PyObject *o2)
     166.. c:function:: PyObject* PyNumber_InPlaceFloorDivide(PyObject *o1, PyObject *o2)
    167167
    168168   Returns the mathematical floor of dividing *o1* by *o2*, or *NULL* on failure.
     
    173173
    174174
    175 .. cfunction:: PyObject* PyNumber_InPlaceTrueDivide(PyObject *o1, PyObject *o2)
     175.. c:function:: PyObject* PyNumber_InPlaceTrueDivide(PyObject *o1, PyObject *o2)
    176176
    177177   Return a reasonable approximation for the mathematical value of *o1* divided by
     
    184184
    185185
    186 .. cfunction:: PyObject* PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2)
     186.. c:function:: PyObject* PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2)
    187187
    188188   Returns the remainder of dividing *o1* by *o2*, or *NULL* on failure.  The
     
    191191
    192192
    193 .. cfunction:: PyObject* PyNumber_InPlacePower(PyObject *o1, PyObject *o2, PyObject *o3)
     193.. c:function:: PyObject* PyNumber_InPlacePower(PyObject *o1, PyObject *o2, PyObject *o3)
    194194
    195195   .. index:: builtin: pow
     
    197197   See the built-in function :func:`pow`. Returns *NULL* on failure.  The operation
    198198   is done *in-place* when *o1* supports it.  This is the equivalent of the Python
    199    statement ``o1 **= o2`` when o3 is :cdata:`Py_None`, or an in-place variant of
    200    ``pow(o1, o2, o3)`` otherwise. If *o3* is to be ignored, pass :cdata:`Py_None`
     199   statement ``o1 **= o2`` when o3 is :c:data:`Py_None`, or an in-place variant of
     200   ``pow(o1, o2, o3)`` otherwise. If *o3* is to be ignored, pass :c:data:`Py_None`
    201201   in its place (passing *NULL* for *o3* would cause an illegal memory access).
    202202
    203203
    204 .. cfunction:: PyObject* PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2)
     204.. c:function:: PyObject* PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2)
    205205
    206206   Returns the result of left shifting *o1* by *o2* on success, or *NULL* on
     
    209209
    210210
    211 .. cfunction:: PyObject* PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2)
     211.. c:function:: PyObject* PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2)
    212212
    213213   Returns the result of right shifting *o1* by *o2* on success, or *NULL* on
     
    216216
    217217
    218 .. cfunction:: PyObject* PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2)
     218.. c:function:: PyObject* PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2)
    219219
    220220   Returns the "bitwise and" of *o1* and *o2* on success and *NULL* on failure. The
     
    223223
    224224
    225 .. cfunction:: PyObject* PyNumber_InPlaceXor(PyObject *o1, PyObject *o2)
     225.. c:function:: PyObject* PyNumber_InPlaceXor(PyObject *o1, PyObject *o2)
    226226
    227227   Returns the "bitwise exclusive or" of *o1* by *o2* on success, or *NULL* on
     
    230230
    231231
    232 .. cfunction:: PyObject* PyNumber_InPlaceOr(PyObject *o1, PyObject *o2)
     232.. c:function:: PyObject* PyNumber_InPlaceOr(PyObject *o1, PyObject *o2)
    233233
    234234   Returns the "bitwise or" of *o1* and *o2* on success, or *NULL* on failure.  The
     
    237237
    238238
    239 .. cfunction:: int PyNumber_Coerce(PyObject **p1, PyObject **p2)
     239.. c:function:: int PyNumber_Coerce(PyObject **p1, PyObject **p2)
    240240
    241241   .. index:: builtin: coerce
    242242
    243    This function takes the addresses of two variables of type :ctype:`PyObject\*`.
     243   This function takes the addresses of two variables of type :c:type:`PyObject\*`.
    244244   If the objects pointed to by ``*p1`` and ``*p2`` have the same type, increment
    245245   their reference count and return ``0`` (success). If the objects can be
     
    251251
    252252
    253 .. cfunction:: int PyNumber_CoerceEx(PyObject **p1, PyObject **p2)
    254 
    255    This function is similar to :cfunc:`PyNumber_Coerce`, except that it returns
     253.. c:function:: int PyNumber_CoerceEx(PyObject **p1, PyObject **p2)
     254
     255   This function is similar to :c:func:`PyNumber_Coerce`, except that it returns
    256256   ``1`` when the conversion is not possible and when no error is raised.
    257257   Reference counts are still not increased in this case.
    258258
    259259
    260 .. cfunction:: PyObject* PyNumber_Int(PyObject *o)
     260.. c:function:: PyObject* PyNumber_Int(PyObject *o)
    261261
    262262   .. index:: builtin: int
     
    267267
    268268
    269 .. cfunction:: PyObject* PyNumber_Long(PyObject *o)
     269.. c:function:: PyObject* PyNumber_Long(PyObject *o)
    270270
    271271   .. index:: builtin: long
     
    275275
    276276
    277 .. cfunction:: PyObject* PyNumber_Float(PyObject *o)
     277.. c:function:: PyObject* PyNumber_Float(PyObject *o)
    278278
    279279   .. index:: builtin: float
     
    283283
    284284
    285 .. cfunction:: PyObject* PyNumber_Index(PyObject *o)
     285.. c:function:: PyObject* PyNumber_Index(PyObject *o)
    286286
    287287   Returns the *o* converted to a Python int or long on success or *NULL* with a
     
    291291
    292292
    293 .. cfunction:: PyObject* PyNumber_ToBase(PyObject *n, int base)
     293.. c:function:: PyObject* PyNumber_ToBase(PyObject *n, int base)
    294294
    295295   Returns the integer *n* converted to *base* as a string with a base
     
    297297   *base* is not 2, 8, 10, or 16, the format is ``'x#num'`` where x is the
    298298   base. If *n* is not an int object, it is converted with
    299    :cfunc:`PyNumber_Index` first.
     299   :c:func:`PyNumber_Index` first.
    300300
    301301   .. versionadded:: 2.6
    302302
    303303
    304 .. cfunction:: Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc)
     304.. c:function:: Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc)
    305305
    306306   Returns *o* converted to a Py_ssize_t value if *o* can be interpreted as an
     
    315315
    316316
    317 .. cfunction:: int PyIndex_Check(PyObject *o)
     317.. c:function:: int PyIndex_Check(PyObject *o)
    318318
    319319   Returns True if *o* is an index integer (has the nb_index slot of  the
  • python/vendor/current/Doc/c-api/objbuffer.rst

    r2 r388  
    33.. _abstract-buffer:
    44
     5
    56Old Buffer Protocol
    67===================
    78
    8 
    99This section describes the legacy buffer protocol, which has been introduced
    1010in Python 1.6. It is still supported but deprecated in the Python 2.x series.
    11 Python 3.0 introduces a new buffer protocol which fixes weaknesses and
     11Python 3 introduces a new buffer protocol which fixes weaknesses and
    1212shortcomings of the protocol, and has been backported to Python 2.6.  See
    1313:ref:`bufferobjects` for more information.
    1414
    1515
    16 .. cfunction:: int PyObject_AsCharBuffer(PyObject *obj, const char **buffer, Py_ssize_t *buffer_len)
     16.. c:function:: int PyObject_AsCharBuffer(PyObject *obj, const char **buffer, Py_ssize_t *buffer_len)
    1717
    1818   Returns a pointer to a read-only memory location usable as character-based
     
    2525
    2626   .. versionchanged:: 2.5
    27       This function used an :ctype:`int *` type for *buffer_len*. This might
     27      This function used an :c:type:`int *` type for *buffer_len*. This might
    2828      require changes in your code for properly supporting 64-bit systems.
    2929
    3030
    31 .. cfunction:: int PyObject_AsReadBuffer(PyObject *obj, const void **buffer, Py_ssize_t *buffer_len)
     31.. c:function:: int PyObject_AsReadBuffer(PyObject *obj, const void **buffer, Py_ssize_t *buffer_len)
    3232
    3333   Returns a pointer to a read-only memory location containing arbitrary data.
     
    4040
    4141   .. versionchanged:: 2.5
    42       This function used an :ctype:`int *` type for *buffer_len*. This might
     42      This function used an :c:type:`int *` type for *buffer_len*. This might
    4343      require changes in your code for properly supporting 64-bit systems.
    4444
    4545
    46 .. cfunction:: int PyObject_CheckReadBuffer(PyObject *o)
     46.. c:function:: int PyObject_CheckReadBuffer(PyObject *o)
    4747
    4848   Returns ``1`` if *o* supports the single-segment readable buffer interface.
     
    5252
    5353
    54 .. cfunction:: int PyObject_AsWriteBuffer(PyObject *obj, void **buffer, Py_ssize_t *buffer_len)
     54.. c:function:: int PyObject_AsWriteBuffer(PyObject *obj, void **buffer, Py_ssize_t *buffer_len)
    5555
    5656   Returns a pointer to a writeable memory location.  The *obj* argument must
     
    6262
    6363   .. versionchanged:: 2.5
    64       This function used an :ctype:`int *` type for *buffer_len*. This might
     64      This function used an :c:type:`int *` type for *buffer_len*. This might
    6565      require changes in your code for properly supporting 64-bit systems.
    6666
  • python/vendor/current/Doc/c-api/object.rst

    r2 r388  
    77
    88
    9 .. cfunction:: int PyObject_Print(PyObject *o, FILE *fp, int flags)
     9.. c:function:: int PyObject_Print(PyObject *o, FILE *fp, int flags)
    1010
    1111   Print an object *o*, on file *fp*.  Returns ``-1`` on error.  The flags argument
     
    1515
    1616
    17 .. cfunction:: int PyObject_HasAttr(PyObject *o, PyObject *attr_name)
     17.. c:function:: int PyObject_HasAttr(PyObject *o, PyObject *attr_name)
    1818
    1919   Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise.  This
     
    2222
    2323
    24 .. cfunction:: int PyObject_HasAttrString(PyObject *o, const char *attr_name)
     24.. c:function:: int PyObject_HasAttrString(PyObject *o, const char *attr_name)
    2525
    2626   Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise.  This
     
    2929
    3030
    31 .. cfunction:: PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name)
     31.. c:function:: PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name)
    3232
    3333   Retrieve an attribute named *attr_name* from object *o*. Returns the attribute
     
    3636
    3737
    38 .. cfunction:: PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name)
     38.. c:function:: PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name)
    3939
    4040   Retrieve an attribute named *attr_name* from object *o*. Returns the attribute
     
    4343
    4444
    45 .. cfunction:: PyObject* PyObject_GenericGetAttr(PyObject *o, PyObject *name)
     45.. c:function:: PyObject* PyObject_GenericGetAttr(PyObject *o, PyObject *name)
    4646
    4747   Generic attribute getter function that is meant to be put into a type
    4848   object's ``tp_getattro`` slot.  It looks for a descriptor in the dictionary
    4949   of classes in the object's MRO as well as an attribute in the object's
    50    :attr:`__dict__` (if present).  As outlined in :ref:`descriptors`, data
    51    descriptors take preference over instance attributes, while non-data
     50   :attr:`~object.__dict__` (if present).  As outlined in :ref:`descriptors`,
     51   data descriptors take preference over instance attributes, while non-data
    5252   descriptors don't.  Otherwise, an :exc:`AttributeError` is raised.
    5353
    5454
    55 .. cfunction:: int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v)
     55.. c:function:: int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v)
    5656
    5757   Set the value of the attribute named *attr_name*, for object *o*, to the value
     
    6060
    6161
    62 .. cfunction:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v)
     62.. c:function:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v)
    6363
    6464   Set the value of the attribute named *attr_name*, for object *o*, to the value
     
    6767
    6868
    69 .. cfunction:: int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value)
     69.. c:function:: int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value)
    7070
    7171   Generic attribute setter function that is meant to be put into a type
     
    7373   dictionary of classes in the object's MRO, and if found it takes preference
    7474   over setting the attribute in the instance dictionary. Otherwise, the
    75    attribute is set in the object's :attr:`__dict__` (if present).  Otherwise,
    76    an :exc:`AttributeError` is raised and ``-1`` is returned.
    77 
    78 
    79 .. cfunction:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name)
     75   attribute is set in the object's :attr:`~object.__dict__` (if present).
     76   Otherwise, an :exc:`AttributeError` is raised and ``-1`` is returned.
     77
     78
     79.. c:function:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name)
    8080
    8181   Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on failure.
     
    8383
    8484
    85 .. cfunction:: int PyObject_DelAttrString(PyObject *o, const char *attr_name)
     85.. c:function:: int PyObject_DelAttrString(PyObject *o, const char *attr_name)
    8686
    8787   Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on failure.
     
    8989
    9090
    91 .. cfunction:: PyObject* PyObject_RichCompare(PyObject *o1, PyObject *o2, int opid)
     91.. c:function:: PyObject* PyObject_RichCompare(PyObject *o1, PyObject *o2, int opid)
    9292
    9393   Compare the values of *o1* and *o2* using the operation specified by *opid*,
     
    9999
    100100
    101 .. cfunction:: int PyObject_RichCompareBool(PyObject *o1, PyObject *o2, int opid)
     101.. c:function:: int PyObject_RichCompareBool(PyObject *o1, PyObject *o2, int opid)
    102102
    103103   Compare the values of *o1* and *o2* using the operation specified by *opid*,
     
    109109   *opid*.
    110110
    111 
    112 .. cfunction:: int PyObject_Cmp(PyObject *o1, PyObject *o2, int *result)
     111.. note::
     112   If *o1* and *o2* are the same object, :c:func:`PyObject_RichCompareBool`
     113   will always return ``1`` for :const:`Py_EQ` and ``0`` for :const:`Py_NE`.
     114
     115.. c:function:: int PyObject_Cmp(PyObject *o1, PyObject *o2, int *result)
    113116
    114117   .. index:: builtin: cmp
     
    120123
    121124
    122 .. cfunction:: int PyObject_Compare(PyObject *o1, PyObject *o2)
     125.. c:function:: int PyObject_Compare(PyObject *o1, PyObject *o2)
    123126
    124127   .. index:: builtin: cmp
     
    127130   exists, otherwise with a routine provided by *o2*.  Returns the result of the
    128131   comparison on success.  On error, the value returned is undefined; use
    129    :cfunc:`PyErr_Occurred` to detect an error.  This is equivalent to the Python
     132   :c:func:`PyErr_Occurred` to detect an error.  This is equivalent to the Python
    130133   expression ``cmp(o1, o2)``.
    131134
    132135
    133 .. cfunction:: PyObject* PyObject_Repr(PyObject *o)
     136.. c:function:: PyObject* PyObject_Repr(PyObject *o)
    134137
    135138   .. index:: builtin: repr
     
    141144
    142145
    143 .. cfunction:: PyObject* PyObject_Str(PyObject *o)
     146.. c:function:: PyObject* PyObject_Str(PyObject *o)
    144147
    145148   .. index:: builtin: str
     
    151154
    152155
    153 .. cfunction:: PyObject* PyObject_Bytes(PyObject *o)
     156.. c:function:: PyObject* PyObject_Bytes(PyObject *o)
    154157
    155158   .. index:: builtin: bytes
    156159
    157160   Compute a bytes representation of object *o*.  In 2.x, this is just a alias
    158    for :cfunc:`PyObject_Str`.
    159 
    160 
    161 .. cfunction:: PyObject* PyObject_Unicode(PyObject *o)
     161   for :c:func:`PyObject_Str`.
     162
     163
     164.. c:function:: PyObject* PyObject_Unicode(PyObject *o)
    162165
    163166   .. index:: builtin: unicode
     
    169172
    170173
    171 .. cfunction:: int PyObject_IsInstance(PyObject *inst, PyObject *cls)
     174.. c:function:: int PyObject_IsInstance(PyObject *inst, PyObject *cls)
    172175
    173176   Returns ``1`` if *inst* is an instance of the class *cls* or a subclass of
    174177   *cls*, or ``0`` if not.  On error, returns ``-1`` and sets an exception.  If
    175    *cls* is a type object rather than a class object, :cfunc:`PyObject_IsInstance`
     178   *cls* is a type object rather than a class object, :c:func:`PyObject_IsInstance`
    176179   returns ``1`` if *inst* is of type *cls*.  If *cls* is a tuple, the check will
    177180   be done against every entry in *cls*. The result will be ``1`` when at least one
    178181   of the checks returns ``1``, otherwise it will be ``0``. If *inst* is not a
    179182   class instance and *cls* is neither a type object, nor a class object, nor a
    180    tuple, *inst* must have a :attr:`__class__` attribute --- the class relationship
    181    of the value of that attribute with *cls* will be used to determine the result
    182    of this function.
     183   tuple, *inst* must have a :attr:`~instance.__class__` attribute --- the
     184   class relationship of the value of that attribute with *cls* will be used
     185   to determine the result of this function.
    183186
    184187   .. versionadded:: 2.1
     
    193196either is not a class object, a more general mechanism is used to determine the
    194197class relationship of the two objects.  When testing if *B* is a subclass of
    195 *A*, if *A* is *B*, :cfunc:`PyObject_IsSubclass` returns true.  If *A* and *B*
    196 are different objects, *B*'s :attr:`__bases__` attribute is searched in a
    197 depth-first fashion for *A* --- the presence of the :attr:`__bases__` attribute
    198 is considered sufficient for this determination.
    199 
    200 
    201 .. cfunction:: int PyObject_IsSubclass(PyObject *derived, PyObject *cls)
     198*A*, if *A* is *B*, :c:func:`PyObject_IsSubclass` returns true.  If *A* and *B*
     199are different objects, *B*'s :attr:`~class.__bases__` attribute is searched in
     200a depth-first fashion for *A* --- the presence of the :attr:`~class.__bases__`
     201attribute is considered sufficient for this determination.
     202
     203
     204.. c:function:: int PyObject_IsSubclass(PyObject *derived, PyObject *cls)
    202205
    203206   Returns ``1`` if the class *derived* is identical to or derived from the class
     
    214217
    215218
    216 .. cfunction:: int PyCallable_Check(PyObject *o)
     219.. c:function:: int PyCallable_Check(PyObject *o)
    217220
    218221   Determine if the object *o* is callable.  Return ``1`` if the object is callable
     
    220223
    221224
    222 .. cfunction:: PyObject* PyObject_Call(PyObject *callable_object, PyObject *args, PyObject *kw)
     225.. c:function:: PyObject* PyObject_Call(PyObject *callable_object, PyObject *args, PyObject *kw)
    223226
    224227   .. index:: builtin: apply
     
    234237
    235238
    236 .. cfunction:: PyObject* PyObject_CallObject(PyObject *callable_object, PyObject *args)
     239.. c:function:: PyObject* PyObject_CallObject(PyObject *callable_object, PyObject *args)
    237240
    238241   .. index:: builtin: apply
     
    245248
    246249
    247 .. cfunction:: PyObject* PyObject_CallFunction(PyObject *callable, char *format, ...)
     250.. c:function:: PyObject* PyObject_CallFunction(PyObject *callable, char *format, ...)
    248251
    249252   .. index:: builtin: apply
    250253
    251254   Call a callable Python object *callable*, with a variable number of C arguments.
    252    The C arguments are described using a :cfunc:`Py_BuildValue` style format
     255   The C arguments are described using a :c:func:`Py_BuildValue` style format
    253256   string.  The format may be *NULL*, indicating that no arguments are provided.
    254257   Returns the result of the call on success, or *NULL* on failure.  This is the
    255258   equivalent of the Python expression ``apply(callable, args)`` or
    256    ``callable(*args)``. Note that if you only pass :ctype:`PyObject \*` args,
    257    :cfunc:`PyObject_CallFunctionObjArgs` is a faster alternative.
    258 
    259 
    260 .. cfunction:: PyObject* PyObject_CallMethod(PyObject *o, char *method, char *format, ...)
     259   ``callable(*args)``. Note that if you only pass :c:type:`PyObject \*` args,
     260   :c:func:`PyObject_CallFunctionObjArgs` is a faster alternative.
     261
     262
     263.. c:function:: PyObject* PyObject_CallMethod(PyObject *o, char *method, char *format, ...)
    261264
    262265   Call the method named *method* of object *o* with a variable number of C
    263    arguments.  The C arguments are described by a :cfunc:`Py_BuildValue` format
     266   arguments.  The C arguments are described by a :c:func:`Py_BuildValue` format
    264267   string that should  produce a tuple.  The format may be *NULL*, indicating that
    265268   no arguments are provided. Returns the result of the call on success, or *NULL*
    266269   on failure.  This is the equivalent of the Python expression ``o.method(args)``.
    267    Note that if you only pass :ctype:`PyObject \*` args,
    268    :cfunc:`PyObject_CallMethodObjArgs` is a faster alternative.
    269 
    270 
    271 .. cfunction:: PyObject* PyObject_CallFunctionObjArgs(PyObject *callable, ..., NULL)
     270   Note that if you only pass :c:type:`PyObject \*` args,
     271   :c:func:`PyObject_CallMethodObjArgs` is a faster alternative.
     272
     273
     274.. c:function:: PyObject* PyObject_CallFunctionObjArgs(PyObject *callable, ..., NULL)
    272275
    273276   Call a callable Python object *callable*, with a variable number of
    274    :ctype:`PyObject\*` arguments.  The arguments are provided as a variable number
     277   :c:type:`PyObject\*` arguments.  The arguments are provided as a variable number
    275278   of parameters followed by *NULL*. Returns the result of the call on success, or
    276279   *NULL* on failure.
     
    279282
    280283
    281 .. cfunction:: PyObject* PyObject_CallMethodObjArgs(PyObject *o, PyObject *name, ..., NULL)
     284.. c:function:: PyObject* PyObject_CallMethodObjArgs(PyObject *o, PyObject *name, ..., NULL)
    282285
    283286   Calls a method of the object *o*, where the name of the method is given as a
    284287   Python string object in *name*.  It is called with a variable number of
    285    :ctype:`PyObject\*` arguments.  The arguments are provided as a variable number
     288   :c:type:`PyObject\*` arguments.  The arguments are provided as a variable number
    286289   of parameters followed by *NULL*. Returns the result of the call on success, or
    287290   *NULL* on failure.
     
    290293
    291294
    292 .. cfunction:: long PyObject_Hash(PyObject *o)
     295.. c:function:: long PyObject_Hash(PyObject *o)
    293296
    294297   .. index:: builtin: hash
     
    298301
    299302
    300 .. cfunction:: long PyObject_HashNotImplemented(PyObject *o)
     303.. c:function:: long PyObject_HashNotImplemented(PyObject *o)
    301304
    302305   Set a :exc:`TypeError` indicating that ``type(o)`` is not hashable and return ``-1``.
     
    308311
    309312
    310 .. cfunction:: int PyObject_IsTrue(PyObject *o)
     313.. c:function:: int PyObject_IsTrue(PyObject *o)
    311314
    312315   Returns ``1`` if the object *o* is considered to be true, and ``0`` otherwise.
     
    315318
    316319
    317 .. cfunction:: int PyObject_Not(PyObject *o)
     320.. c:function:: int PyObject_Not(PyObject *o)
    318321
    319322   Returns ``0`` if the object *o* is considered to be true, and ``1`` otherwise.
     
    322325
    323326
    324 .. cfunction:: PyObject* PyObject_Type(PyObject *o)
     327.. c:function:: PyObject* PyObject_Type(PyObject *o)
    325328
    326329   .. index:: builtin: type
     
    331334   reference count of the return value. There's really no reason to use this
    332335   function instead of the common expression ``o->ob_type``, which returns a
    333    pointer of type :ctype:`PyTypeObject\*`, except when the incremented reference
     336   pointer of type :c:type:`PyTypeObject\*`, except when the incremented reference
    334337   count is needed.
    335338
    336339
    337 .. cfunction:: int PyObject_TypeCheck(PyObject *o, PyTypeObject *type)
     340.. c:function:: int PyObject_TypeCheck(PyObject *o, PyTypeObject *type)
    338341
    339342   Return true if the object *o* is of type *type* or a subtype of *type*.  Both
     
    343346
    344347
    345 .. cfunction:: Py_ssize_t PyObject_Length(PyObject *o)
     348.. c:function:: Py_ssize_t PyObject_Length(PyObject *o)
    346349               Py_ssize_t PyObject_Size(PyObject *o)
    347350
     
    353356
    354357   .. versionchanged:: 2.5
    355       These functions returned an :ctype:`int` type. This might require
     358      These functions returned an :c:type:`int` type. This might require
    356359      changes in your code for properly supporting 64-bit systems.
    357360
    358361
    359 .. cfunction:: PyObject* PyObject_GetItem(PyObject *o, PyObject *key)
     362.. c:function:: PyObject* PyObject_GetItem(PyObject *o, PyObject *key)
    360363
    361364   Return element of *o* corresponding to the object *key* or *NULL* on failure.
     
    363366
    364367
    365 .. cfunction:: int PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v)
     368.. c:function:: int PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v)
    366369
    367370   Map the object *key* to the value *v*.  Returns ``-1`` on failure.  This is the
     
    369372
    370373
    371 .. cfunction:: int PyObject_DelItem(PyObject *o, PyObject *key)
     374.. c:function:: int PyObject_DelItem(PyObject *o, PyObject *key)
    372375
    373376   Delete the mapping for *key* from *o*.  Returns ``-1`` on failure. This is the
     
    375378
    376379
    377 .. cfunction:: int PyObject_AsFileDescriptor(PyObject *o)
     380.. c:function:: int PyObject_AsFileDescriptor(PyObject *o)
    378381
    379382   Derives a file descriptor from a Python object.  If the object is an integer or
     
    383386
    384387
    385 .. cfunction:: PyObject* PyObject_Dir(PyObject *o)
     388.. c:function:: PyObject* PyObject_Dir(PyObject *o)
    386389
    387390   This is equivalent to the Python expression ``dir(o)``, returning a (possibly
     
    389392   was an error.  If the argument is *NULL*, this is like the Python ``dir()``,
    390393   returning the names of the current locals; in this case, if no execution frame
    391    is active then *NULL* is returned but :cfunc:`PyErr_Occurred` will return false.
    392 
    393 
    394 .. cfunction:: PyObject* PyObject_GetIter(PyObject *o)
     394   is active then *NULL* is returned but :c:func:`PyErr_Occurred` will return false.
     395
     396
     397.. c:function:: PyObject* PyObject_GetIter(PyObject *o)
    395398
    396399   This is equivalent to the Python expression ``iter(o)``. It returns a new
  • python/vendor/current/Doc/c-api/refcounting.rst

    r2 r388  
    1212
    1313
    14 .. cfunction:: void Py_INCREF(PyObject *o)
     14.. c:function:: void Py_INCREF(PyObject *o)
    1515
    1616   Increment the reference count for object *o*.  The object must not be *NULL*; if
    17    you aren't sure that it isn't *NULL*, use :cfunc:`Py_XINCREF`.
     17   you aren't sure that it isn't *NULL*, use :c:func:`Py_XINCREF`.
    1818
    1919
    20 .. cfunction:: void Py_XINCREF(PyObject *o)
     20.. c:function:: void Py_XINCREF(PyObject *o)
    2121
    2222   Increment the reference count for object *o*.  The object may be *NULL*, in
     
    2424
    2525
    26 .. cfunction:: void Py_DECREF(PyObject *o)
     26.. c:function:: void Py_DECREF(PyObject *o)
    2727
    2828   Decrement the reference count for object *o*.  The object must not be *NULL*; if
    29    you aren't sure that it isn't *NULL*, use :cfunc:`Py_XDECREF`.  If the reference
     29   you aren't sure that it isn't *NULL*, use :c:func:`Py_XDECREF`.  If the reference
    3030   count reaches zero, the object's type's deallocation function (which must not be
    3131   *NULL*) is invoked.
     
    3737      exceptions in such code are not propagated, the executed code has free access to
    3838      all Python global variables.  This means that any object that is reachable from
    39       a global variable should be in a consistent state before :cfunc:`Py_DECREF` is
     39      a global variable should be in a consistent state before :c:func:`Py_DECREF` is
    4040      invoked.  For example, code to delete an object from a list should copy a
    4141      reference to the deleted object in a temporary variable, update the list data
    42       structure, and then call :cfunc:`Py_DECREF` for the temporary variable.
     42      structure, and then call :c:func:`Py_DECREF` for the temporary variable.
    4343
    4444
    45 .. cfunction:: void Py_XDECREF(PyObject *o)
     45.. c:function:: void Py_XDECREF(PyObject *o)
    4646
    4747   Decrement the reference count for object *o*.  The object may be *NULL*, in
    4848   which case the macro has no effect; otherwise the effect is the same as for
    49    :cfunc:`Py_DECREF`, and the same warning applies.
     49   :c:func:`Py_DECREF`, and the same warning applies.
    5050
    5151
    52 .. cfunction:: void Py_CLEAR(PyObject *o)
     52.. c:function:: void Py_CLEAR(PyObject *o)
    5353
    5454   Decrement the reference count for object *o*.  The object may be *NULL*, in
    5555   which case the macro has no effect; otherwise the effect is the same as for
    56    :cfunc:`Py_DECREF`, except that the argument is also set to *NULL*.  The warning
    57    for :cfunc:`Py_DECREF` does not apply with respect to the object passed because
     56   :c:func:`Py_DECREF`, except that the argument is also set to *NULL*.  The warning
     57   for :c:func:`Py_DECREF` does not apply with respect to the object passed because
    5858   the macro carefully uses a temporary variable and sets the argument to *NULL*
    5959   before decrementing its reference count.
     
    6666The following functions are for runtime dynamic embedding of Python:
    6767``Py_IncRef(PyObject *o)``, ``Py_DecRef(PyObject *o)``. They are
    68 simply exported function versions of :cfunc:`Py_XINCREF` and
    69 :cfunc:`Py_XDECREF`, respectively.
     68simply exported function versions of :c:func:`Py_XINCREF` and
     69:c:func:`Py_XDECREF`, respectively.
    7070
    7171The following functions or macros are only for use within the interpreter core:
    72 :cfunc:`_Py_Dealloc`, :cfunc:`_Py_ForgetReference`, :cfunc:`_Py_NewReference`,
    73 as well as the global variable :cdata:`_Py_RefTotal`.
     72:c:func:`_Py_Dealloc`, :c:func:`_Py_ForgetReference`, :c:func:`_Py_NewReference`,
     73as well as the global variable :c:data:`_Py_RefTotal`.
    7474
  • python/vendor/current/Doc/c-api/reflection.rst

    r2 r388  
    66==========
    77
    8 .. cfunction:: PyObject* PyEval_GetBuiltins()
     8.. c:function:: PyObject* PyEval_GetBuiltins()
    99
    1010   Return a dictionary of the builtins in the current execution frame,
     
    1212
    1313
    14 .. cfunction:: PyObject* PyEval_GetLocals()
     14.. c:function:: PyObject* PyEval_GetLocals()
    1515
    1616   Return a dictionary of the local variables in the current execution frame,
     
    1818
    1919
    20 .. cfunction:: PyObject* PyEval_GetGlobals()
     20.. c:function:: PyObject* PyEval_GetGlobals()
    2121
    2222   Return a dictionary of the global variables in the current execution frame,
     
    2424
    2525
    26 .. cfunction:: PyFrameObject* PyEval_GetFrame()
     26.. c:function:: PyFrameObject* PyEval_GetFrame()
    2727
    2828   Return the current thread state's frame, which is *NULL* if no frame is
     
    3030
    3131
    32 .. cfunction:: int PyEval_GetRestricted()
     32.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
     33
     34   Return the line number that *frame* is currently executing.
     35
     36
     37.. c:function:: int PyEval_GetRestricted()
    3338
    3439   If there is a current frame and it is executing in restricted mode, return true,
     
    3641
    3742
    38 .. cfunction:: const char* PyEval_GetFuncName(PyObject *func)
     43.. c:function:: const char* PyEval_GetFuncName(PyObject *func)
    3944
    4045   Return the name of *func* if it is a function, class or instance object, else the
     
    4247
    4348
    44 .. cfunction:: const char* PyEval_GetFuncDesc(PyObject *func)
     49.. c:function:: const char* PyEval_GetFuncDesc(PyObject *func)
    4550
    4651   Return a description string, depending on the type of *func*.
    4752   Return values include "()" for functions and methods, " constructor",
    4853   " instance", and " object".  Concatenated with the result of
    49    :cfunc:`PyEval_GetFuncName`, the result will be a description of
     54   :c:func:`PyEval_GetFuncName`, the result will be a description of
    5055   *func*.
  • python/vendor/current/Doc/c-api/sequence.rst

    r2 r388  
    77
    88
    9 .. cfunction:: int PySequence_Check(PyObject *o)
     9.. c:function:: int PySequence_Check(PyObject *o)
    1010
    1111   Return ``1`` if the object provides sequence protocol, and ``0`` otherwise.
     
    1313
    1414
    15 .. cfunction:: Py_ssize_t PySequence_Size(PyObject *o)
     15.. c:function:: Py_ssize_t PySequence_Size(PyObject *o)
    1616               Py_ssize_t PySequence_Length(PyObject *o)
    1717
     
    2323
    2424   .. versionchanged:: 2.5
    25       These functions returned an :ctype:`int` type. This might require
    26       changes in your code for properly supporting 64-bit systems.
    27 
    28 
    29 .. cfunction:: PyObject* PySequence_Concat(PyObject *o1, PyObject *o2)
     25      These functions returned an :c:type:`int` type. This might require
     26      changes in your code for properly supporting 64-bit systems.
     27
     28
     29.. c:function:: PyObject* PySequence_Concat(PyObject *o1, PyObject *o2)
    3030
    3131   Return the concatenation of *o1* and *o2* on success, and *NULL* on failure.
     
    3333
    3434
    35 .. cfunction:: PyObject* PySequence_Repeat(PyObject *o, Py_ssize_t count)
     35.. c:function:: PyObject* PySequence_Repeat(PyObject *o, Py_ssize_t count)
    3636
    3737   Return the result of repeating sequence object *o* *count* times, or *NULL* on
     
    3939
    4040   .. versionchanged:: 2.5
    41       This function used an :ctype:`int` type for *count*. This might require
    42       changes in your code for properly supporting 64-bit systems.
    43 
    44 
    45 .. cfunction:: PyObject* PySequence_InPlaceConcat(PyObject *o1, PyObject *o2)
     41      This function used an :c:type:`int` type for *count*. This might require
     42      changes in your code for properly supporting 64-bit systems.
     43
     44
     45.. c:function:: PyObject* PySequence_InPlaceConcat(PyObject *o1, PyObject *o2)
    4646
    4747   Return the concatenation of *o1* and *o2* on success, and *NULL* on failure.
     
    5050
    5151
    52 .. cfunction:: PyObject* PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count)
     52.. c:function:: PyObject* PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count)
    5353
    5454   Return the result of repeating sequence object *o* *count* times, or *NULL* on
     
    5757
    5858   .. versionchanged:: 2.5
    59       This function used an :ctype:`int` type for *count*. This might require
    60       changes in your code for properly supporting 64-bit systems.
    61 
    62 
    63 .. cfunction:: PyObject* PySequence_GetItem(PyObject *o, Py_ssize_t i)
     59      This function used an :c:type:`int` type for *count*. This might require
     60      changes in your code for properly supporting 64-bit systems.
     61
     62
     63.. c:function:: PyObject* PySequence_GetItem(PyObject *o, Py_ssize_t i)
    6464
    6565   Return the *i*\ th element of *o*, or *NULL* on failure. This is the equivalent of
     
    6767
    6868   .. versionchanged:: 2.5
    69       This function used an :ctype:`int` type for *i*. This might require
    70       changes in your code for properly supporting 64-bit systems.
    71 
    72 
    73 .. cfunction:: PyObject* PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2)
     69      This function used an :c:type:`int` type for *i*. This might require
     70      changes in your code for properly supporting 64-bit systems.
     71
     72
     73.. c:function:: PyObject* PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2)
    7474
    7575   Return the slice of sequence object *o* between *i1* and *i2*, or *NULL* on
     
    7777
    7878   .. versionchanged:: 2.5
    79       This function used an :ctype:`int` type for *i1* and *i2*. This might
     79      This function used an :c:type:`int` type for *i1* and *i2*. This might
    8080      require changes in your code for properly supporting 64-bit systems.
    8181
    8282
    83 .. cfunction:: int PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v)
     83.. c:function:: int PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v)
    8484
    8585   Assign object *v* to the *i*\ th element of *o*.  Returns ``-1`` on failure.  This
     
    8888
    8989   .. versionchanged:: 2.5
    90       This function used an :ctype:`int` type for *i*. This might require
    91       changes in your code for properly supporting 64-bit systems.
    92 
    93 
    94 .. cfunction:: int PySequence_DelItem(PyObject *o, Py_ssize_t i)
     90      This function used an :c:type:`int` type for *i*. This might require
     91      changes in your code for properly supporting 64-bit systems.
     92
     93
     94.. c:function:: int PySequence_DelItem(PyObject *o, Py_ssize_t i)
    9595
    9696   Delete the *i*\ th element of object *o*.  Returns ``-1`` on failure.  This is the
     
    9898
    9999   .. versionchanged:: 2.5
    100       This function used an :ctype:`int` type for *i*. This might require
    101       changes in your code for properly supporting 64-bit systems.
    102 
    103 
    104 .. cfunction:: int PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2, PyObject *v)
     100      This function used an :c:type:`int` type for *i*. This might require
     101      changes in your code for properly supporting 64-bit systems.
     102
     103
     104.. c:function:: int PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2, PyObject *v)
    105105
    106106   Assign the sequence object *v* to the slice in sequence object *o* from *i1* to
     
    108108
    109109   .. versionchanged:: 2.5
    110       This function used an :ctype:`int` type for *i1* and *i2*. This might
     110      This function used an :c:type:`int` type for *i1* and *i2*. This might
    111111      require changes in your code for properly supporting 64-bit systems.
    112112
    113113
    114 .. cfunction:: int PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2)
     114.. c:function:: int PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2)
    115115
    116116   Delete the slice in sequence object *o* from *i1* to *i2*.  Returns ``-1`` on
     
    118118
    119119   .. versionchanged:: 2.5
    120       This function used an :ctype:`int` type for *i1* and *i2*. This might
     120      This function used an :c:type:`int` type for *i1* and *i2*. This might
    121121      require changes in your code for properly supporting 64-bit systems.
    122122
    123123
    124 .. cfunction:: Py_ssize_t PySequence_Count(PyObject *o, PyObject *value)
     124.. c:function:: Py_ssize_t PySequence_Count(PyObject *o, PyObject *value)
    125125
    126126   Return the number of occurrences of *value* in *o*, that is, return the number
     
    129129
    130130   .. versionchanged:: 2.5
    131       This function returned an :ctype:`int` type. This might require changes
     131      This function returned an :c:type:`int` type. This might require changes
    132132      in your code for properly supporting 64-bit systems.
    133133
    134134
    135 .. cfunction:: int PySequence_Contains(PyObject *o, PyObject *value)
     135.. c:function:: int PySequence_Contains(PyObject *o, PyObject *value)
    136136
    137137   Determine if *o* contains *value*.  If an item in *o* is equal to *value*,
     
    140140
    141141
    142 .. cfunction:: Py_ssize_t PySequence_Index(PyObject *o, PyObject *value)
     142.. c:function:: Py_ssize_t PySequence_Index(PyObject *o, PyObject *value)
    143143
    144144   Return the first index *i* for which ``o[i] == value``.  On error, return
     
    146146
    147147   .. versionchanged:: 2.5
    148       This function returned an :ctype:`int` type. This might require changes
     148      This function returned an :c:type:`int` type. This might require changes
    149149      in your code for properly supporting 64-bit systems.
    150150
    151151
    152 .. cfunction:: PyObject* PySequence_List(PyObject *o)
     152.. c:function:: PyObject* PySequence_List(PyObject *o)
    153153
    154154   Return a list object with the same contents as the arbitrary sequence *o*.  The
     
    156156
    157157
    158 .. cfunction:: PyObject* PySequence_Tuple(PyObject *o)
     158.. c:function:: PyObject* PySequence_Tuple(PyObject *o)
    159159
    160160   .. index:: builtin: tuple
     
    166166
    167167
    168 .. cfunction:: PyObject* PySequence_Fast(PyObject *o, const char *m)
     168.. c:function:: PyObject* PySequence_Fast(PyObject *o, const char *m)
    169169
    170170   Returns the sequence *o* as a tuple, unless it is already a tuple or list, in
    171    which case *o* is returned.  Use :cfunc:`PySequence_Fast_GET_ITEM` to access the
     171   which case *o* is returned.  Use :c:func:`PySequence_Fast_GET_ITEM` to access the
    172172   members of the result.  Returns *NULL* on failure.  If the object is not a
    173173   sequence, raises :exc:`TypeError` with *m* as the message text.
    174174
    175175
    176 .. cfunction:: PyObject* PySequence_Fast_GET_ITEM(PyObject *o, Py_ssize_t i)
     176.. c:function:: PyObject* PySequence_Fast_GET_ITEM(PyObject *o, Py_ssize_t i)
    177177
    178178   Return the *i*\ th element of *o*, assuming that *o* was returned by
    179    :cfunc:`PySequence_Fast`, *o* is not *NULL*, and that *i* is within bounds.
    180 
    181    .. versionchanged:: 2.5
    182       This function used an :ctype:`int` type for *i*. This might require
    183       changes in your code for properly supporting 64-bit systems.
    184 
    185 
    186 .. cfunction:: PyObject** PySequence_Fast_ITEMS(PyObject *o)
     179   :c:func:`PySequence_Fast`, *o* is not *NULL*, and that *i* is within bounds.
     180
     181   .. versionchanged:: 2.5
     182      This function used an :c:type:`int` type for *i*. This might require
     183      changes in your code for properly supporting 64-bit systems.
     184
     185
     186.. c:function:: PyObject** PySequence_Fast_ITEMS(PyObject *o)
    187187
    188188   Return the underlying array of PyObject pointers.  Assumes that *o* was returned
    189    by :cfunc:`PySequence_Fast` and *o* is not *NULL*.
     189   by :c:func:`PySequence_Fast` and *o* is not *NULL*.
    190190
    191191   Note, if a list gets resized, the reallocation may relocate the items array.
     
    196196
    197197
    198 .. cfunction:: PyObject* PySequence_ITEM(PyObject *o, Py_ssize_t i)
     198.. c:function:: PyObject* PySequence_ITEM(PyObject *o, Py_ssize_t i)
    199199
    200200   Return the *i*\ th element of *o* or *NULL* on failure. Macro form of
    201    :cfunc:`PySequence_GetItem` but without checking that
    202    :cfunc:`PySequence_Check(o)` is true and without adjustment for negative
     201   :c:func:`PySequence_GetItem` but without checking that
     202   :c:func:`PySequence_Check` on *o* is true and without adjustment for negative
    203203   indices.
    204204
     
    206206
    207207   .. versionchanged:: 2.5
    208       This function used an :ctype:`int` type for *i*. This might require
    209       changes in your code for properly supporting 64-bit systems.
    210 
    211 
    212 .. cfunction:: Py_ssize_t PySequence_Fast_GET_SIZE(PyObject *o)
     208      This function used an :c:type:`int` type for *i*. This might require
     209      changes in your code for properly supporting 64-bit systems.
     210
     211
     212.. c:function:: Py_ssize_t PySequence_Fast_GET_SIZE(PyObject *o)
    213213
    214214   Returns the length of *o*, assuming that *o* was returned by
    215    :cfunc:`PySequence_Fast` and that *o* is not *NULL*.  The size can also be
    216    gotten by calling :cfunc:`PySequence_Size` on *o*, but
    217    :cfunc:`PySequence_Fast_GET_SIZE` is faster because it can assume *o* is a list
     215   :c:func:`PySequence_Fast` and that *o* is not *NULL*.  The size can also be
     216   gotten by calling :c:func:`PySequence_Size` on *o*, but
     217   :c:func:`PySequence_Fast_GET_SIZE` is faster because it can assume *o* is a list
    218218   or tuple.
  • python/vendor/current/Doc/c-api/set.rst

    r2 r388  
    1717This section details the public API for :class:`set` and :class:`frozenset`
    1818objects.  Any functionality not listed below is best accessed using the either
    19 the abstract object protocol (including :cfunc:`PyObject_CallMethod`,
    20 :cfunc:`PyObject_RichCompareBool`, :cfunc:`PyObject_Hash`,
    21 :cfunc:`PyObject_Repr`, :cfunc:`PyObject_IsTrue`, :cfunc:`PyObject_Print`, and
    22 :cfunc:`PyObject_GetIter`) or the abstract number protocol (including
    23 :cfunc:`PyNumber_And`, :cfunc:`PyNumber_Subtract`, :cfunc:`PyNumber_Or`,
    24 :cfunc:`PyNumber_Xor`, :cfunc:`PyNumber_InPlaceAnd`,
    25 :cfunc:`PyNumber_InPlaceSubtract`, :cfunc:`PyNumber_InPlaceOr`, and
    26 :cfunc:`PyNumber_InPlaceXor`).
     19the abstract object protocol (including :c:func:`PyObject_CallMethod`,
     20:c:func:`PyObject_RichCompareBool`, :c:func:`PyObject_Hash`,
     21:c:func:`PyObject_Repr`, :c:func:`PyObject_IsTrue`, :c:func:`PyObject_Print`, and
     22:c:func:`PyObject_GetIter`) or the abstract number protocol (including
     23:c:func:`PyNumber_And`, :c:func:`PyNumber_Subtract`, :c:func:`PyNumber_Or`,
     24:c:func:`PyNumber_Xor`, :c:func:`PyNumber_InPlaceAnd`,
     25:c:func:`PyNumber_InPlaceSubtract`, :c:func:`PyNumber_InPlaceOr`, and
     26:c:func:`PyNumber_InPlaceXor`).
    2727
    2828
    29 .. ctype:: PySetObject
     29.. c:type:: PySetObject
    3030
    31    This subtype of :ctype:`PyObject` is used to hold the internal data for both
    32    :class:`set` and :class:`frozenset` objects.  It is like a :ctype:`PyDictObject`
     31   This subtype of :c:type:`PyObject` is used to hold the internal data for both
     32   :class:`set` and :class:`frozenset` objects.  It is like a :c:type:`PyDictObject`
    3333   in that it is a fixed size for small sets (much like tuple storage) and will
    3434   point to a separate, variable sized block of memory for medium and large sized
     
    3838
    3939
    40 .. cvar:: PyTypeObject PySet_Type
     40.. c:var:: PyTypeObject PySet_Type
    4141
    42    This is an instance of :ctype:`PyTypeObject` representing the Python
     42   This is an instance of :c:type:`PyTypeObject` representing the Python
    4343   :class:`set` type.
    4444
    4545
    46 .. cvar:: PyTypeObject PyFrozenSet_Type
     46.. c:var:: PyTypeObject PyFrozenSet_Type
    4747
    48    This is an instance of :ctype:`PyTypeObject` representing the Python
     48   This is an instance of :c:type:`PyTypeObject` representing the Python
    4949   :class:`frozenset` type.
    5050
     
    5353
    5454
    55 .. cfunction:: int PySet_Check(PyObject *p)
     55.. c:function:: int PySet_Check(PyObject *p)
    5656
    5757   Return true if *p* is a :class:`set` object or an instance of a subtype.
     
    5959   .. versionadded:: 2.6
    6060
    61 .. cfunction:: int PyFrozenSet_Check(PyObject *p)
     61.. c:function:: int PyFrozenSet_Check(PyObject *p)
    6262
    6363   Return true if *p* is a :class:`frozenset` object or an instance of a
     
    6666   .. versionadded:: 2.6
    6767
    68 .. cfunction:: int PyAnySet_Check(PyObject *p)
     68.. c:function:: int PyAnySet_Check(PyObject *p)
    6969
    7070   Return true if *p* is a :class:`set` object, a :class:`frozenset` object, or an
     
    7272
    7373
    74 .. cfunction:: int PyAnySet_CheckExact(PyObject *p)
     74.. c:function:: int PyAnySet_CheckExact(PyObject *p)
    7575
    7676   Return true if *p* is a :class:`set` object or a :class:`frozenset` object but
     
    7878
    7979
    80 .. cfunction:: int PyFrozenSet_CheckExact(PyObject *p)
     80.. c:function:: int PyFrozenSet_CheckExact(PyObject *p)
    8181
    8282   Return true if *p* is a :class:`frozenset` object but not an instance of a
     
    8484
    8585
    86 .. cfunction:: PyObject* PySet_New(PyObject *iterable)
     86.. c:function:: PyObject* PySet_New(PyObject *iterable)
    8787
    8888   Return a new :class:`set` containing objects returned by the *iterable*.  The
     
    9393
    9494
    95 .. cfunction:: PyObject* PyFrozenSet_New(PyObject *iterable)
     95.. c:function:: PyObject* PyFrozenSet_New(PyObject *iterable)
    9696
    9797   Return a new :class:`frozenset` containing objects returned by the *iterable*.
     
    109109
    110110
    111 .. cfunction:: Py_ssize_t PySet_Size(PyObject *anyset)
     111.. c:function:: Py_ssize_t PySet_Size(PyObject *anyset)
    112112
    113113   .. index:: builtin: len
     
    118118
    119119   .. versionchanged:: 2.5
    120       This function returned an :ctype:`int`. This might require changes in
     120      This function returned an :c:type:`int`. This might require changes in
    121121      your code for properly supporting 64-bit systems.
    122122
    123123
    124 .. cfunction:: Py_ssize_t PySet_GET_SIZE(PyObject *anyset)
     124.. c:function:: Py_ssize_t PySet_GET_SIZE(PyObject *anyset)
    125125
    126    Macro form of :cfunc:`PySet_Size` without error checking.
     126   Macro form of :c:func:`PySet_Size` without error checking.
    127127
    128128
    129 .. cfunction:: int PySet_Contains(PyObject *anyset, PyObject *key)
     129.. c:function:: int PySet_Contains(PyObject *anyset, PyObject *key)
    130130
    131131   Return 1 if found, 0 if not found, and -1 if an error is encountered.  Unlike
     
    136136
    137137
    138 .. cfunction:: int PySet_Add(PyObject *set, PyObject *key)
     138.. c:function:: int PySet_Add(PyObject *set, PyObject *key)
    139139
    140140   Add *key* to a :class:`set` instance.  Does not apply to :class:`frozenset`
     
    146146   .. versionchanged:: 2.6
    147147      Now works with instances of :class:`frozenset` or its subtypes.
    148       Like :cfunc:`PyTuple_SetItem` in that it can be used to fill-in the
     148      Like :c:func:`PyTuple_SetItem` in that it can be used to fill-in the
    149149      values of brand new frozensets before they are exposed to other code.
    150150
     
    153153
    154154
    155 .. cfunction:: int PySet_Discard(PyObject *set, PyObject *key)
     155.. c:function:: int PySet_Discard(PyObject *set, PyObject *key)
    156156
    157157   Return 1 if found and removed, 0 if not found (no action taken), and -1 if an
    158158   error is encountered.  Does not raise :exc:`KeyError` for missing keys.  Raise a
    159    :exc:`TypeError` if the *key* is unhashable.  Unlike the Python :meth:`discard`
     159   :exc:`TypeError` if the *key* is unhashable.  Unlike the Python :meth:`~set.discard`
    160160   method, this function does not automatically convert unhashable sets into
    161161   temporary frozensets. Raise :exc:`PyExc_SystemError` if *set* is an not an
     
    163163
    164164
    165 .. cfunction:: PyObject* PySet_Pop(PyObject *set)
     165.. c:function:: PyObject* PySet_Pop(PyObject *set)
    166166
    167167   Return a new reference to an arbitrary object in the *set*, and removes the
     
    171171
    172172
    173 .. cfunction:: int PySet_Clear(PyObject *set)
     173.. c:function:: int PySet_Clear(PyObject *set)
    174174
    175175   Empty an existing set of all elements.
  • python/vendor/current/Doc/c-api/slice.rst

    r2 r388  
    77
    88
    9 .. cvar:: PyTypeObject PySlice_Type
     9.. c:var:: PyTypeObject PySlice_Type
    1010
    1111   .. index:: single: SliceType (in module types)
     
    1515
    1616
    17 .. cfunction:: int PySlice_Check(PyObject *ob)
     17.. c:function:: int PySlice_Check(PyObject *ob)
    1818
    1919   Return true if *ob* is a slice object; *ob* must not be *NULL*.
    2020
    2121
    22 .. cfunction:: PyObject* PySlice_New(PyObject *start, PyObject *stop, PyObject *step)
     22.. c:function:: PyObject* PySlice_New(PyObject *start, PyObject *stop, PyObject *step)
    2323
    2424   Return a new slice object with the given values.  The *start*, *stop*, and
     
    2929
    3030
    31 .. cfunction:: int PySlice_GetIndices(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step)
     31.. c:function:: int PySlice_GetIndices(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step)
    3232
    3333   Retrieve the start, stop and step indices from the slice object *slice*,
     
    4141   You probably do not want to use this function.  If you want to use slice
    4242   objects in versions of Python prior to 2.3, you would probably do well to
    43    incorporate the source of :cfunc:`PySlice_GetIndicesEx`, suitably renamed,
     43   incorporate the source of :c:func:`PySlice_GetIndicesEx`, suitably renamed,
    4444   in the source of your extension.
    4545
    4646   .. versionchanged:: 2.5
    47       This function used an :ctype:`int` type for *length* and an
    48       :ctype:`int *` type for *start*, *stop*, and *step*. This might require
     47      This function used an :c:type:`int` type for *length* and an
     48      :c:type:`int *` type for *start*, *stop*, and *step*. This might require
    4949      changes in your code for properly supporting 64-bit systems.
    5050
    5151
    52 .. cfunction:: int PySlice_GetIndicesEx(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, Py_ssize_t *slicelength)
     52.. c:function:: int PySlice_GetIndicesEx(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, Py_ssize_t *slicelength)
    5353
    54    Usable replacement for :cfunc:`PySlice_GetIndices`.  Retrieve the start,
     54   Usable replacement for :c:func:`PySlice_GetIndices`.  Retrieve the start,
    5555   stop, and step indices from the slice object *slice* assuming a sequence of
    5656   length *length*, and store the length of the slice in *slicelength*.  Out
     
    6363
    6464   .. versionchanged:: 2.5
    65       This function used an :ctype:`int` type for *length* and an
    66       :ctype:`int *` type for *start*, *stop*, *step*, and *slicelength*. This
     65      This function used an :c:type:`int` type for *length* and an
     66      :c:type:`int *` type for *start*, *stop*, *step*, and *slicelength*. This
    6767      might require changes in your code for properly supporting 64-bit
    6868      systems.
  • python/vendor/current/Doc/c-api/string.rst

    r2 r388  
    1818
    1919
    20 .. ctype:: PyStringObject
    21 
    22    This subtype of :ctype:`PyObject` represents a Python string object.
    23 
    24 
    25 .. cvar:: PyTypeObject PyString_Type
     20.. c:type:: PyStringObject
     21
     22   This subtype of :c:type:`PyObject` represents a Python string object.
     23
     24
     25.. c:var:: PyTypeObject PyString_Type
    2626
    2727   .. index:: single: StringType (in module types)
    2828
    29    This instance of :ctype:`PyTypeObject` represents the Python string type; it is
     29   This instance of :c:type:`PyTypeObject` represents the Python string type; it is
    3030   the same object as ``str`` and ``types.StringType`` in the Python layer. .
    3131
    3232
    33 .. cfunction:: int PyString_Check(PyObject *o)
     33.. c:function:: int PyString_Check(PyObject *o)
    3434
    3535   Return true if the object *o* is a string object or an instance of a subtype of
     
    4040
    4141
    42 .. cfunction:: int PyString_CheckExact(PyObject *o)
     42.. c:function:: int PyString_CheckExact(PyObject *o)
    4343
    4444   Return true if the object *o* is a string object, but not an instance of a
     
    4848
    4949
    50 .. cfunction:: PyObject* PyString_FromString(const char *v)
     50.. c:function:: PyObject* PyString_FromString(const char *v)
    5151
    5252   Return a new string object with a copy of the string *v* as value on success,
     
    5555
    5656
    57 .. cfunction:: PyObject* PyString_FromStringAndSize(const char *v, Py_ssize_t len)
     57.. c:function:: PyObject* PyString_FromStringAndSize(const char *v, Py_ssize_t len)
    5858
    5959   Return a new string object with a copy of the string *v* as value and length
     
    6262
    6363   .. versionchanged:: 2.5
    64       This function used an :ctype:`int` type for *len*. This might require
     64      This function used an :c:type:`int` type for *len*. This might require
    6565      changes in your code for properly supporting 64-bit systems.
    6666
    6767
    68 .. cfunction:: PyObject* PyString_FromFormat(const char *format, ...)
    69 
    70    Take a C :cfunc:`printf`\ -style *format* string and a variable number of
     68.. c:function:: PyObject* PyString_FromFormat(const char *format, ...)
     69
     70   Take a C :c:func:`printf`\ -style *format* string and a variable number of
    7171   arguments, calculate the size of the resulting Python string and return a string
    7272   with the values formatted into it.  The variable arguments must be C types and
     
    7979   .. % because not all compilers support the %z width modifier -- we fake it
    8080   .. % when necessary via interpolating PY_FORMAT_SIZE_T.
     81   .. % Similar comments apply to the %ll width modifier and
     82   .. % PY_FORMAT_LONG_LONG.
    8183   .. % %u, %lu, %zu should have "new in Python 2.5" blurbs.
    8284
     
    100102   | :attr:`%lu`       | unsigned long | Exactly equivalent to          |
    101103   |                   |               | ``printf("%lu")``.             |
     104   +-------------------+---------------+--------------------------------+
     105   | :attr:`%lld`      | long long     | Exactly equivalent to          |
     106   |                   |               | ``printf("%lld")``.            |
     107   +-------------------+---------------+--------------------------------+
     108   | :attr:`%llu`      | unsigned      | Exactly equivalent to          |
     109   |                   | long long     | ``printf("%llu")``.            |
    102110   +-------------------+---------------+--------------------------------+
    103111   | :attr:`%zd`       | Py_ssize_t    | Exactly equivalent to          |
     
    128136   copied as-is to the result string, and any extra arguments discarded.
    129137
    130 
    131 .. cfunction:: PyObject* PyString_FromFormatV(const char *format, va_list vargs)
    132 
    133    Identical to :cfunc:`PyString_FromFormat` except that it takes exactly two
     138   .. note::
     139
     140      The `"%lld"` and `"%llu"` format specifiers are only available
     141      when :const:`HAVE_LONG_LONG` is defined.
     142
     143   .. versionchanged:: 2.7
     144      Support for `"%lld"` and `"%llu"` added.
     145
     146
     147.. c:function:: PyObject* PyString_FromFormatV(const char *format, va_list vargs)
     148
     149   Identical to :c:func:`PyString_FromFormat` except that it takes exactly two
    134150   arguments.
    135151
    136152
    137 .. cfunction:: Py_ssize_t PyString_Size(PyObject *string)
     153.. c:function:: Py_ssize_t PyString_Size(PyObject *string)
    138154
    139155   Return the length of the string in string object *string*.
    140156
    141157   .. versionchanged:: 2.5
    142       This function returned an :ctype:`int` type. This might require changes
     158      This function returned an :c:type:`int` type. This might require changes
    143159      in your code for properly supporting 64-bit systems.
    144160
    145161
    146 .. cfunction:: Py_ssize_t PyString_GET_SIZE(PyObject *string)
    147 
    148    Macro form of :cfunc:`PyString_Size` but without error checking.
    149 
    150    .. versionchanged:: 2.5
    151       This macro returned an :ctype:`int` type. This might require changes in
     162.. c:function:: Py_ssize_t PyString_GET_SIZE(PyObject *string)
     163
     164   Macro form of :c:func:`PyString_Size` but without error checking.
     165
     166   .. versionchanged:: 2.5
     167      This macro returned an :c:type:`int` type. This might require changes in
    152168      your code for properly supporting 64-bit systems.
    153169
    154170
    155 .. cfunction:: char* PyString_AsString(PyObject *string)
     171.. c:function:: char* PyString_AsString(PyObject *string)
    156172
    157173   Return a NUL-terminated representation of the contents of *string*.  The pointer
     
    161177   *string* is a Unicode object, this function computes the default encoding of
    162178   *string* and operates on that.  If *string* is not a string object at all,
    163    :cfunc:`PyString_AsString` returns *NULL* and raises :exc:`TypeError`.
    164 
    165 
    166 .. cfunction:: char* PyString_AS_STRING(PyObject *string)
    167 
    168    Macro form of :cfunc:`PyString_AsString` but without error checking.  Only
     179   :c:func:`PyString_AsString` returns *NULL* and raises :exc:`TypeError`.
     180
     181
     182.. c:function:: char* PyString_AS_STRING(PyObject *string)
     183
     184   Macro form of :c:func:`PyString_AsString` but without error checking.  Only
    169185   string objects are supported; no Unicode objects should be passed.
    170186
    171187
    172 .. cfunction:: int PyString_AsStringAndSize(PyObject *obj, char **buffer, Py_ssize_t *length)
     188.. c:function:: int PyString_AsStringAndSize(PyObject *obj, char **buffer, Py_ssize_t *length)
    173189
    174190   Return a NUL-terminated representation of the contents of the object *obj*
     
    185201   *string* is a Unicode object, this function computes the default encoding of
    186202   *string* and operates on that.  If *string* is not a string object at all,
    187    :cfunc:`PyString_AsStringAndSize` returns ``-1`` and raises :exc:`TypeError`.
    188 
    189    .. versionchanged:: 2.5
    190       This function used an :ctype:`int *` type for *length*. This might
     203   :c:func:`PyString_AsStringAndSize` returns ``-1`` and raises :exc:`TypeError`.
     204
     205   .. versionchanged:: 2.5
     206      This function used an :c:type:`int *` type for *length*. This might
    191207      require changes in your code for properly supporting 64-bit systems.
    192208
    193209
    194 .. cfunction:: void PyString_Concat(PyObject **string, PyObject *newpart)
     210.. c:function:: void PyString_Concat(PyObject **string, PyObject *newpart)
    195211
    196212   Create a new string object in *\*string* containing the contents of *newpart*
     
    201217
    202218
    203 .. cfunction:: void PyString_ConcatAndDel(PyObject **string, PyObject *newpart)
     219.. c:function:: void PyString_ConcatAndDel(PyObject **string, PyObject *newpart)
    204220
    205221   Create a new string object in *\*string* containing the contents of *newpart*
     
    207223
    208224
    209 .. cfunction:: int _PyString_Resize(PyObject **string, Py_ssize_t newsize)
     225.. c:function:: int _PyString_Resize(PyObject **string, Py_ssize_t newsize)
    210226
    211227   A way to resize a string object even though it is "immutable". Only use this to
     
    220236
    221237   .. versionchanged:: 2.5
    222       This function used an :ctype:`int` type for *newsize*. This might
     238      This function used an :c:type:`int` type for *newsize*. This might
    223239      require changes in your code for properly supporting 64-bit systems.
    224240
    225 .. cfunction:: PyObject* PyString_Format(PyObject *format, PyObject *args)
     241.. c:function:: PyObject* PyString_Format(PyObject *format, PyObject *args)
    226242
    227243   Return a new string object from *format* and *args*. Analogous to ``format %
    228    args``.  The *args* argument must be a tuple.
    229 
    230 
    231 .. cfunction:: void PyString_InternInPlace(PyObject **string)
     244   args``.  The *args* argument must be a tuple or dict.
     245
     246
     247.. c:function:: void PyString_InternInPlace(PyObject **string)
    232248
    233249   Intern the argument *\*string* in place.  The argument must be the address of a
     
    246262
    247263
    248 .. cfunction:: PyObject* PyString_InternFromString(const char *v)
    249 
    250    A combination of :cfunc:`PyString_FromString` and
    251    :cfunc:`PyString_InternInPlace`, returning either a new string object that has
     264.. c:function:: PyObject* PyString_InternFromString(const char *v)
     265
     266   A combination of :c:func:`PyString_FromString` and
     267   :c:func:`PyString_InternInPlace`, returning either a new string object that has
    252268   been interned, or a new ("owned") reference to an earlier interned string object
    253269   with the same value.
     
    258274
    259275
    260 .. cfunction:: PyObject* PyString_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)
     276.. c:function:: PyObject* PyString_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)
    261277
    262278   Create an object by decoding *size* bytes of the encoded buffer *s* using the
     
    271287
    272288   .. versionchanged:: 2.5
    273       This function used an :ctype:`int` type for *size*. This might require
     289      This function used an :c:type:`int` type for *size*. This might require
    274290      changes in your code for properly supporting 64-bit systems.
    275291
    276292
    277 .. cfunction:: PyObject* PyString_AsDecodedObject(PyObject *str, const char *encoding, const char *errors)
     293.. c:function:: PyObject* PyString_AsDecodedObject(PyObject *str, const char *encoding, const char *errors)
    278294
    279295   Decode a string object by passing it to the codec registered for *encoding* and
     
    288304
    289305
    290 .. cfunction:: PyObject* PyString_Encode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)
    291 
    292    Encode the :ctype:`char` buffer of the given size by passing it to the codec
     306.. c:function:: PyObject* PyString_Encode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)
     307
     308   Encode the :c:type:`char` buffer of the given size by passing it to the codec
    293309   registered for *encoding* and return a Python object. *encoding* and *errors*
    294310   have the same meaning as the parameters of the same name in the string
     
    301317
    302318   .. versionchanged:: 2.5
    303       This function used an :ctype:`int` type for *size*. This might require
     319      This function used an :c:type:`int` type for *size*. This might require
    304320      changes in your code for properly supporting 64-bit systems.
    305321
    306322
    307 .. cfunction:: PyObject* PyString_AsEncodedObject(PyObject *str, const char *encoding, const char *errors)
     323.. c:function:: PyObject* PyString_AsEncodedObject(PyObject *str, const char *encoding, const char *errors)
    308324
    309325   Encode a string object using the codec registered for *encoding* and return the
  • python/vendor/current/Doc/c-api/structures.rst

    r2 r388  
    1212All Python objects ultimately share a small number of fields at the beginning
    1313of the object's representation in memory.  These are represented by the
    14 :ctype:`PyObject` and :ctype:`PyVarObject` types, which are defined, in turn,
     14:c:type:`PyObject` and :c:type:`PyVarObject` types, which are defined, in turn,
    1515by the expansions of some macros also used, whether directly or indirectly, in
    1616the definition of all other Python objects.
    1717
    1818
    19 .. ctype:: PyObject
     19.. c:type:: PyObject
    2020
    2121   All object types are extensions of this type.  This is a type which
     
    2727
    2828
    29 .. ctype:: PyVarObject
    30 
    31    This is an extension of :ctype:`PyObject` that adds the :attr:`ob_size`
     29.. c:type:: PyVarObject
     30
     31   This is an extension of :c:type:`PyObject` that adds the :attr:`ob_size`
    3232   field.  This is only used for objects that have some notion of *length*.
    3333   This type does not often appear in the Python/C API.  It corresponds to the
    3434   fields defined by the expansion of the ``PyObject_VAR_HEAD`` macro.
    3535
    36 These macros are used in the definition of :ctype:`PyObject` and
    37 :ctype:`PyVarObject`:
    38 
    39 
    40 .. cmacro:: PyObject_HEAD
     36These macros are used in the definition of :c:type:`PyObject` and
     37:c:type:`PyVarObject`:
     38
     39
     40.. c:macro:: PyObject_HEAD
    4141
    4242   This is a macro which expands to the declarations of the fields of the
    43    :ctype:`PyObject` type; it is used when declaring new types which represent
     43   :c:type:`PyObject` type; it is used when declaring new types which represent
    4444   objects without a varying length.  The specific fields it expands to depend
    45    on the definition of :cmacro:`Py_TRACE_REFS`.  By default, that macro is
    46    not defined, and :cmacro:`PyObject_HEAD` expands to::
     45   on the definition of :c:macro:`Py_TRACE_REFS`.  By default, that macro is
     46   not defined, and :c:macro:`PyObject_HEAD` expands to::
    4747
    4848      Py_ssize_t ob_refcnt;
    4949      PyTypeObject *ob_type;
    5050
    51    When :cmacro:`Py_TRACE_REFS` is defined, it expands to::
     51   When :c:macro:`Py_TRACE_REFS` is defined, it expands to::
    5252
    5353      PyObject *_ob_next, *_ob_prev;
     
    5656
    5757
    58 .. cmacro:: PyObject_VAR_HEAD
     58.. c:macro:: PyObject_VAR_HEAD
    5959
    6060   This is a macro which expands to the declarations of the fields of the
    61    :ctype:`PyVarObject` type; it is used when declaring new types which
     61   :c:type:`PyVarObject` type; it is used when declaring new types which
    6262   represent objects with a length that varies from instance to instance.
    6363   This macro always expands to::
     
    6666      Py_ssize_t ob_size;
    6767
    68    Note that :cmacro:`PyObject_HEAD` is part of the expansion, and that its own
    69    expansion varies depending on the definition of :cmacro:`Py_TRACE_REFS`.
    70 
    71 
    72 .. cmacro:: PyObject_HEAD_INIT(type)
     68   Note that :c:macro:`PyObject_HEAD` is part of the expansion, and that its own
     69   expansion varies depending on the definition of :c:macro:`Py_TRACE_REFS`.
     70
     71
     72.. c:macro:: PyObject_HEAD_INIT(type)
    7373
    7474   This is a macro which expands to initialization values for a new
    75    :ctype:`PyObject` type.  This macro expands to::
     75   :c:type:`PyObject` type.  This macro expands to::
    7676
    7777      _PyObject_EXTRA_INIT
     
    7979
    8080
    81 .. cmacro:: PyVarObject_HEAD_INIT(type, size)
     81.. c:macro:: PyVarObject_HEAD_INIT(type, size)
    8282
    8383   This is a macro which expands to initialization values for a new
    84    :ctype:`PyVarObject` type, including the :attr:`ob_size` field.
     84   :c:type:`PyVarObject` type, including the :attr:`ob_size` field.
    8585   This macro expands to::
    8686
     
    8989
    9090
    91 .. ctype:: PyCFunction
     91.. c:type:: PyCFunction
    9292
    9393   Type of the functions used to implement most Python callables in C.
    94    Functions of this type take two :ctype:`PyObject\*` parameters and return
     94   Functions of this type take two :c:type:`PyObject\*` parameters and return
    9595   one such value.  If the return value is *NULL*, an exception shall have
    9696   been set.  If not *NULL*, the return value is interpreted as the return
     
    9999
    100100
    101 .. ctype:: PyMethodDef
     101.. c:type:: PyMethodDef
    102102
    103103   Structure used to describe a method of an extension type.  This structure has
     
    120120
    121121The :attr:`ml_meth` is a C function pointer.  The functions may be of different
    122 types, but they always return :ctype:`PyObject\*`.  If the function is not of
    123 the :ctype:`PyCFunction`, the compiler will require a cast in the method table.
    124 Even though :ctype:`PyCFunction` defines the first parameter as
    125 :ctype:`PyObject\*`, it is common that the method implementation uses a the
     122types, but they always return :c:type:`PyObject\*`.  If the function is not of
     123the :c:type:`PyCFunction`, the compiler will require a cast in the method table.
     124Even though :c:type:`PyCFunction` defines the first parameter as
     125:c:type:`PyObject\*`, it is common that the method implementation uses a the
    126126specific C type of the *self* object.
    127127
     
    137137
    138138   This is the typical calling convention, where the methods have the type
    139    :ctype:`PyCFunction`. The function expects two :ctype:`PyObject\*` values.
    140    The first one is the *self* object for methods; for module functions, it
    141    has the value given to :cfunc:`Py_InitModule4` (or *NULL* if
    142    :cfunc:`Py_InitModule` was used).  The second parameter (often called
    143    *args*) is a tuple object representing all arguments. This parameter is
    144    typically processed using :cfunc:`PyArg_ParseTuple` or
    145    :cfunc:`PyArg_UnpackTuple`.
     139   :c:type:`PyCFunction`. The function expects two :c:type:`PyObject\*` values.
     140   The first one is the *self* object for methods; for module functions, it is
     141   the module object.  The second parameter (often called *args*) is a tuple
     142   object representing all arguments.  This parameter is typically processed
     143   using :c:func:`PyArg_ParseTuple` or :c:func:`PyArg_UnpackTuple`.
    146144
    147145
    148146.. data:: METH_KEYWORDS
    149147
    150    Methods with these flags must be of type :ctype:`PyCFunctionWithKeywords`.
     148   Methods with these flags must be of type :c:type:`PyCFunctionWithKeywords`.
    151149   The function expects three parameters: *self*, *args*, and a dictionary of
    152150   all the keyword arguments.  The flag is typically combined with
    153151   :const:`METH_VARARGS`, and the parameters are typically processed using
    154    :cfunc:`PyArg_ParseTupleAndKeywords`.
     152   :c:func:`PyArg_ParseTupleAndKeywords`.
    155153
    156154
     
    159157   Methods without parameters don't need to check whether arguments are given if
    160158   they are listed with the :const:`METH_NOARGS` flag.  They need to be of type
    161    :ctype:`PyCFunction`.  When used with object methods, the first parameter is
    162    typically named ``self`` and will hold a reference to the object instance.
    163    In all cases the second parameter will be *NULL*.
     159   :c:type:`PyCFunction`.  The first parameter is typically named ``self`` and
     160   will hold a reference to the module or object instance.  In all cases the
     161   second parameter will be *NULL*.
    164162
    165163
     
    167165
    168166   Methods with a single object argument can be listed with the :const:`METH_O`
    169    flag, instead of invoking :cfunc:`PyArg_ParseTuple` with a ``"O"`` argument.
    170    They have the type :ctype:`PyCFunction`, with the *self* parameter, and a
    171    :ctype:`PyObject\*` parameter representing the single argument.
     167   flag, instead of invoking :c:func:`PyArg_ParseTuple` with a ``"O"`` argument.
     168   They have the type :c:type:`PyCFunction`, with the *self* parameter, and a
     169   :c:type:`PyObject\*` parameter representing the single argument.
    172170
    173171
     
    175173
    176174   This calling convention is deprecated.  The method must be of type
    177    :ctype:`PyCFunction`.  The second argument is *NULL* if no arguments are
     175   :c:type:`PyCFunction`.  The second argument is *NULL* if no arguments are
    178176   given, a single object if exactly one argument is given, and a tuple of
    179177   objects if more than one argument is given.  There is no way for a function
     
    228226
    229227
    230 .. ctype:: PyMemberDef
     228.. c:type:: PyMemberDef
    231229
    232230   Structure which describes an attribute of a type which corresponds to a C
     
    280278   =============== ==================
    281279
    282    :cmacro:`T_OBJECT` and :cmacro:`T_OBJECT_EX` differ in that
    283    :cmacro:`T_OBJECT` returns ``None`` if the member is *NULL* and
    284    :cmacro:`T_OBJECT_EX` raises an :exc:`AttributeError`.  Try to use
    285    :cmacro:`T_OBJECT_EX` over :cmacro:`T_OBJECT` because :cmacro:`T_OBJECT_EX`
     280   :c:macro:`T_OBJECT` and :c:macro:`T_OBJECT_EX` differ in that
     281   :c:macro:`T_OBJECT` returns ``None`` if the member is *NULL* and
     282   :c:macro:`T_OBJECT_EX` raises an :exc:`AttributeError`.  Try to use
     283   :c:macro:`T_OBJECT_EX` over :c:macro:`T_OBJECT` because :c:macro:`T_OBJECT_EX`
    286284   handles use of the :keyword:`del` statement on that attribute more correctly
    287    than :cmacro:`T_OBJECT`.
    288 
    289    :attr:`flags` can be 0 for write and read access or :cmacro:`READONLY` for
    290    read-only access.  Using :cmacro:`T_STRING` for :attr:`type` implies
    291    :cmacro:`READONLY`.  Only :cmacro:`T_OBJECT` and :cmacro:`T_OBJECT_EX`
     285   than :c:macro:`T_OBJECT`.
     286
     287   :attr:`flags` can be 0 for write and read access or :c:macro:`READONLY` for
     288   read-only access.  Using :c:macro:`T_STRING` for :attr:`type` implies
     289   :c:macro:`READONLY`.  Only :c:macro:`T_OBJECT` and :c:macro:`T_OBJECT_EX`
    292290   members can be deleted.  (They are set to *NULL*).
    293291
    294292
    295 .. cfunction:: PyObject* Py_FindMethod(PyMethodDef table[], PyObject *ob, char *name)
     293.. c:function:: PyObject* Py_FindMethod(PyMethodDef table[], PyObject *ob, char *name)
    296294
    297295   Return a bound method object for an extension type implemented in C.  This
    298    can be useful in the implementation of a :attr:`tp_getattro` or
    299    :attr:`tp_getattr` handler that does not use the
    300    :cfunc:`PyObject_GenericGetAttr` function.
     296   can be useful in the implementation of a :c:member:`~PyTypeObject.tp_getattro` or
     297   :c:member:`~PyTypeObject.tp_getattr` handler that does not use the
     298   :c:func:`PyObject_GenericGetAttr` function.
  • python/vendor/current/Doc/c-api/sys.rst

    r2 r388  
    77
    88
    9 .. cfunction:: int Py_FdIsInteractive(FILE *fp, const char *filename)
     9.. c:function:: int Py_FdIsInteractive(FILE *fp, const char *filename)
    1010
    1111   Return true (nonzero) if the standard I/O file *fp* with name *filename* is
    1212   deemed interactive.  This is the case for files for which ``isatty(fileno(fp))``
    13    is true.  If the global flag :cdata:`Py_InteractiveFlag` is true, this function
     13   is true.  If the global flag :c:data:`Py_InteractiveFlag` is true, this function
    1414   also returns true if the *filename* pointer is *NULL* or if the name is equal to
    1515   one of the strings ``'<stdin>'`` or ``'???'``.
    1616
    1717
    18 .. cfunction:: long PyOS_GetLastModificationTime(char *filename)
    19 
    20    Return the time of last modification of the file *filename*. The result is
    21    encoded in the same way as the timestamp returned by the standard C library
    22    function :cfunc:`time`.
    23 
    24 
    25 .. cfunction:: void PyOS_AfterFork()
     18.. c:function:: void PyOS_AfterFork()
    2619
    2720   Function to update some internal state after a process fork; this should be
     
    3124
    3225
    33 .. cfunction:: int PyOS_CheckStack()
     26.. c:function:: int PyOS_CheckStack()
    3427
    3528   Return true when the interpreter runs out of stack space.  This is a reliable
     
    4033
    4134
    42 .. cfunction:: PyOS_sighandler_t PyOS_getsig(int i)
     35.. c:function:: PyOS_sighandler_t PyOS_getsig(int i)
    4336
    4437   Return the current signal handler for signal *i*.  This is a thin wrapper around
    45    either :cfunc:`sigaction` or :cfunc:`signal`.  Do not call those functions
    46    directly! :ctype:`PyOS_sighandler_t` is a typedef alias for :ctype:`void
     38   either :c:func:`sigaction` or :c:func:`signal`.  Do not call those functions
     39   directly! :c:type:`PyOS_sighandler_t` is a typedef alias for :c:type:`void
    4740   (\*)(int)`.
    4841
    4942
    50 .. cfunction:: PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h)
     43.. c:function:: PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h)
    5144
    5245   Set the signal handler for signal *i* to be *h*; return the old signal handler.
    53    This is a thin wrapper around either :cfunc:`sigaction` or :cfunc:`signal`.  Do
    54    not call those functions directly!  :ctype:`PyOS_sighandler_t` is a typedef
    55    alias for :ctype:`void (\*)(int)`.
     46   This is a thin wrapper around either :c:func:`sigaction` or :c:func:`signal`.  Do
     47   not call those functions directly!  :c:type:`PyOS_sighandler_t` is a typedef
     48   alias for :c:type:`void (\*)(int)`.
    5649
    5750.. _systemfunctions:
     
    6457:mod:`sys` module's dict, which is contained in the internal thread state structure.
    6558
    66 .. cfunction:: PyObject *PySys_GetObject(char *name)
     59.. c:function:: PyObject *PySys_GetObject(char *name)
    6760
    6861   Return the object *name* from the :mod:`sys` module or *NULL* if it does
    6962   not exist, without setting an exception.
    7063
    71 .. cfunction:: FILE *PySys_GetFile(char *name, FILE *def)
     64.. c:function:: FILE *PySys_GetFile(char *name, FILE *def)
    7265
    73    Return the :ctype:`FILE*` associated with the object *name* in the
     66   Return the :c:type:`FILE*` associated with the object *name* in the
    7467   :mod:`sys` module, or *def* if *name* is not in the module or is not associated
    75    with a :ctype:`FILE*`.
     68   with a :c:type:`FILE*`.
    7669
    77 .. cfunction:: int PySys_SetObject(char *name, PyObject *v)
     70.. c:function:: int PySys_SetObject(char *name, PyObject *v)
    7871
    7972   Set *name* in the :mod:`sys` module to *v* unless *v* is *NULL*, in which
     
    8174   on error.
    8275
    83 .. cfunction:: void PySys_ResetWarnOptions()
     76.. c:function:: void PySys_ResetWarnOptions()
    8477
    8578   Reset :data:`sys.warnoptions` to an empty list.
    8679
    87 .. cfunction:: void PySys_AddWarnOption(char *s)
     80.. c:function:: void PySys_AddWarnOption(char *s)
    8881
    8982   Append *s* to :data:`sys.warnoptions`.
    9083
    91 .. cfunction:: void PySys_SetPath(char *path)
     84.. c:function:: void PySys_SetPath(char *path)
    9285
    9386   Set :data:`sys.path` to a list object of paths found in *path* which should
     
    9588   (``:`` on Unix, ``;`` on Windows).
    9689
    97 .. cfunction:: void PySys_WriteStdout(const char *format, ...)
     90.. c:function:: void PySys_WriteStdout(const char *format, ...)
    9891
    9992   Write the output string described by *format* to :data:`sys.stdout`.  No
     
    111104   is written to the real (C level) *stdout*.
    112105
    113 .. cfunction:: void PySys_WriteStderr(const char *format, ...)
     106.. c:function:: void PySys_WriteStderr(const char *format, ...)
    114107
    115108   As above, but write to :data:`sys.stderr` or *stderr* instead.
     
    122115
    123116
    124 .. cfunction:: void Py_FatalError(const char *message)
     117.. c:function:: void Py_FatalError(const char *message)
    125118
    126119   .. index:: single: abort()
     
    130123   make it dangerous to continue using the Python interpreter; e.g., when the
    131124   object administration appears to be corrupted.  On Unix, the standard C library
    132    function :cfunc:`abort` is called which will attempt to produce a :file:`core`
     125   function :c:func:`abort` is called which will attempt to produce a :file:`core`
    133126   file.
    134127
    135128
    136 .. cfunction:: void Py_Exit(int status)
     129.. c:function:: void Py_Exit(int status)
    137130
    138131   .. index::
     
    140133      single: exit()
    141134
    142    Exit the current process.  This calls :cfunc:`Py_Finalize` and then calls the
     135   Exit the current process.  This calls :c:func:`Py_Finalize` and then calls the
    143136   standard C library function ``exit(status)``.
    144137
    145138
    146 .. cfunction:: int Py_AtExit(void (*func) ())
     139.. c:function:: int Py_AtExit(void (*func) ())
    147140
    148141   .. index::
     
    150143      single: cleanup functions
    151144
    152    Register a cleanup function to be called by :cfunc:`Py_Finalize`.  The cleanup
     145   Register a cleanup function to be called by :c:func:`Py_Finalize`.  The cleanup
    153146   function will be called with no arguments and should return no value.  At most
    154147   32 cleanup functions can be registered.  When the registration is successful,
    155    :cfunc:`Py_AtExit` returns ``0``; on failure, it returns ``-1``.  The cleanup
     148   :c:func:`Py_AtExit` returns ``0``; on failure, it returns ``-1``.  The cleanup
    156149   function registered last is called first. Each cleanup function will be called
    157150   at most once.  Since Python's internal finalization will have completed before
  • python/vendor/current/Doc/c-api/tuple.rst

    r2 r388  
    99
    1010
    11 .. ctype:: PyTupleObject
     11.. c:type:: PyTupleObject
    1212
    13    This subtype of :ctype:`PyObject` represents a Python tuple object.
     13   This subtype of :c:type:`PyObject` represents a Python tuple object.
    1414
    1515
    16 .. cvar:: PyTypeObject PyTuple_Type
     16.. c:var:: PyTypeObject PyTuple_Type
    1717
    1818   .. index:: single: TupleType (in module types)
    1919
    20    This instance of :ctype:`PyTypeObject` represents the Python tuple type; it is
     20   This instance of :c:type:`PyTypeObject` represents the Python tuple type; it is
    2121   the same object as ``tuple`` and ``types.TupleType`` in the Python layer..
    2222
    2323
    24 .. cfunction:: int PyTuple_Check(PyObject *p)
     24.. c:function:: int PyTuple_Check(PyObject *p)
    2525
    2626   Return true if *p* is a tuple object or an instance of a subtype of the tuple
     
    3131
    3232
    33 .. cfunction:: int PyTuple_CheckExact(PyObject *p)
     33.. c:function:: int PyTuple_CheckExact(PyObject *p)
    3434
    3535   Return true if *p* is a tuple object, but not an instance of a subtype of the
     
    3939
    4040
    41 .. cfunction:: PyObject* PyTuple_New(Py_ssize_t len)
     41.. c:function:: PyObject* PyTuple_New(Py_ssize_t len)
    4242
    4343   Return a new tuple object of size *len*, or *NULL* on failure.
    4444
    4545   .. versionchanged:: 2.5
    46       This function used an :ctype:`int` type for *len*. This might require
     46      This function used an :c:type:`int` type for *len*. This might require
    4747      changes in your code for properly supporting 64-bit systems.
    4848
    4949
    50 .. cfunction:: PyObject* PyTuple_Pack(Py_ssize_t n, ...)
     50.. c:function:: PyObject* PyTuple_Pack(Py_ssize_t n, ...)
    5151
    5252   Return a new tuple object of size *n*, or *NULL* on failure. The tuple values
     
    5757
    5858   .. versionchanged:: 2.5
    59       This function used an :ctype:`int` type for *n*. This might require
     59      This function used an :c:type:`int` type for *n*. This might require
    6060      changes in your code for properly supporting 64-bit systems.
    6161
    6262
    63 .. cfunction:: Py_ssize_t PyTuple_Size(PyObject *p)
     63.. c:function:: Py_ssize_t PyTuple_Size(PyObject *p)
    6464
    6565   Take a pointer to a tuple object, and return the size of that tuple.
    6666
    6767   .. versionchanged:: 2.5
    68       This function returned an :ctype:`int` type. This might require changes
     68      This function returned an :c:type:`int` type. This might require changes
    6969      in your code for properly supporting 64-bit systems.
    7070
    7171
    72 .. cfunction:: Py_ssize_t PyTuple_GET_SIZE(PyObject *p)
     72.. c:function:: Py_ssize_t PyTuple_GET_SIZE(PyObject *p)
    7373
    7474   Return the size of the tuple *p*, which must be non-*NULL* and point to a tuple;
     
    7676
    7777   .. versionchanged:: 2.5
    78       This function returned an :ctype:`int` type. This might require changes
     78      This function returned an :c:type:`int` type. This might require changes
    7979      in your code for properly supporting 64-bit systems.
    8080
    8181
    82 .. cfunction:: PyObject* PyTuple_GetItem(PyObject *p, Py_ssize_t pos)
     82.. c:function:: PyObject* PyTuple_GetItem(PyObject *p, Py_ssize_t pos)
    8383
    8484   Return the object at position *pos* in the tuple pointed to by *p*.  If *pos* is
     
    8686
    8787   .. versionchanged:: 2.5
    88       This function used an :ctype:`int` type for *pos*. This might require
     88      This function used an :c:type:`int` type for *pos*. This might require
    8989      changes in your code for properly supporting 64-bit systems.
    9090
    9191
    92 .. cfunction:: PyObject* PyTuple_GET_ITEM(PyObject *p, Py_ssize_t pos)
     92.. c:function:: PyObject* PyTuple_GET_ITEM(PyObject *p, Py_ssize_t pos)
    9393
    94    Like :cfunc:`PyTuple_GetItem`, but does no checking of its arguments.
     94   Like :c:func:`PyTuple_GetItem`, but does no checking of its arguments.
    9595
    9696   .. versionchanged:: 2.5
    97       This function used an :ctype:`int` type for *pos*. This might require
     97      This function used an :c:type:`int` type for *pos*. This might require
    9898      changes in your code for properly supporting 64-bit systems.
    9999
    100100
    101 .. cfunction:: PyObject* PyTuple_GetSlice(PyObject *p, Py_ssize_t low, Py_ssize_t high)
     101.. c:function:: PyObject* PyTuple_GetSlice(PyObject *p, Py_ssize_t low, Py_ssize_t high)
    102102
    103103   Take a slice of the tuple pointed to by *p* from *low* to *high* and return it
     
    105105
    106106   .. versionchanged:: 2.5
    107       This function used an :ctype:`int` type for *low* and *high*. This might
     107      This function used an :c:type:`int` type for *low* and *high*. This might
    108108      require changes in your code for properly supporting 64-bit systems.
    109109
    110110
    111 .. cfunction:: int PyTuple_SetItem(PyObject *p, Py_ssize_t pos, PyObject *o)
     111.. c:function:: int PyTuple_SetItem(PyObject *p, Py_ssize_t pos, PyObject *o)
    112112
    113113   Insert a reference to object *o* at position *pos* of the tuple pointed to by
     
    119119
    120120   .. versionchanged:: 2.5
    121       This function used an :ctype:`int` type for *pos*. This might require
     121      This function used an :c:type:`int` type for *pos*. This might require
    122122      changes in your code for properly supporting 64-bit systems.
    123123
    124124
    125 .. cfunction:: void PyTuple_SET_ITEM(PyObject *p, Py_ssize_t pos, PyObject *o)
     125.. c:function:: void PyTuple_SET_ITEM(PyObject *p, Py_ssize_t pos, PyObject *o)
    126126
    127    Like :cfunc:`PyTuple_SetItem`, but does no error checking, and should *only* be
     127   Like :c:func:`PyTuple_SetItem`, but does no error checking, and should *only* be
    128128   used to fill in brand new tuples.
    129129
     
    133133
    134134   .. versionchanged:: 2.5
    135       This function used an :ctype:`int` type for *pos*. This might require
     135      This function used an :c:type:`int` type for *pos*. This might require
    136136      changes in your code for properly supporting 64-bit systems.
    137137
    138138
    139 .. cfunction:: int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize)
     139.. c:function:: int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize)
    140140
    141141   Can be used to resize a tuple.  *newsize* will be the new length of the tuple.
     
    154154
    155155   .. versionchanged:: 2.5
    156       This function used an :ctype:`int` type for *newsize*. This might
     156      This function used an :c:type:`int` type for *newsize*. This might
    157157      require changes in your code for properly supporting 64-bit systems.
    158158
    159159
    160 .. cfunction:: int PyTuple_ClearFreeList()
     160.. c:function:: int PyTuple_ClearFreeList()
    161161
    162162   Clear the free list. Return the total number of freed items.
  • python/vendor/current/Doc/c-api/type.rst

    r2 r388  
    99
    1010
    11 .. ctype:: PyTypeObject
     11.. c:type:: PyTypeObject
    1212
    1313   The C structure of the objects used to describe built-in types.
    1414
    1515
    16 .. cvar:: PyObject* PyType_Type
     16.. c:var:: PyObject* PyType_Type
    1717
    1818   .. index:: single: TypeType (in module types)
     
    2222
    2323
    24 .. cfunction:: int PyType_Check(PyObject *o)
     24.. c:function:: int PyType_Check(PyObject *o)
    2525
    2626   Return true if the object *o* is a type object, including instances of types
     
    2828
    2929
    30 .. cfunction:: int PyType_CheckExact(PyObject *o)
     30.. c:function:: int PyType_CheckExact(PyObject *o)
    3131
    3232   Return true if the object *o* is a type object, but not a subtype of the
     
    3636
    3737
    38 .. cfunction:: unsigned int PyType_ClearCache()
     38.. c:function:: unsigned int PyType_ClearCache()
    3939
    4040   Clear the internal lookup cache. Return the current version tag.
     
    4343
    4444
    45 .. cfunction:: void PyType_Modified(PyTypeObject *type)
     45.. c:function:: void PyType_Modified(PyTypeObject *type)
    4646
    4747   Invalidate the internal lookup cache for the type and all of its
     
    5252
    5353
    54 .. cfunction:: int PyType_HasFeature(PyObject *o, int feature)
     54.. c:function:: int PyType_HasFeature(PyObject *o, int feature)
    5555
    5656   Return true if the type object *o* sets the feature *feature*.  Type features
     
    5858
    5959
    60 .. cfunction:: int PyType_IS_GC(PyObject *o)
     60.. c:function:: int PyType_IS_GC(PyObject *o)
    6161
    6262   Return true if the type object includes support for the cycle detector; this
     
    6666
    6767
    68 .. cfunction:: int PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b)
     68.. c:function:: int PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b)
    6969
    7070   Return true if *a* is a subtype of *b*.
     
    7373
    7474
    75 .. cfunction:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
     75.. c:function:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
    7676
    7777   .. versionadded:: 2.2
    7878
    7979   .. versionchanged:: 2.5
    80       This function used an :ctype:`int` type for *nitems*. This might require
     80      This function used an :c:type:`int` type for *nitems*. This might require
    8181      changes in your code for properly supporting 64-bit systems.
    8282
    8383
    84 .. cfunction:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
     84.. c:function:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
    8585
    8686   .. versionadded:: 2.2
    8787
    8888
    89 .. cfunction:: int PyType_Ready(PyTypeObject *type)
     89.. c:function:: int PyType_Ready(PyTypeObject *type)
    9090
    9191   Finalize a type object.  This should be called on all type objects to finish
  • python/vendor/current/Doc/c-api/typeobj.rst

    r2 r388  
    77
    88Perhaps one of the most important structures of the Python object system is the
    9 structure that defines a new type: the :ctype:`PyTypeObject` structure.  Type
    10 objects can be handled using any of the :cfunc:`PyObject_\*` or
    11 :cfunc:`PyType_\*` functions, but do not offer much that's interesting to most
     9structure that defines a new type: the :c:type:`PyTypeObject` structure.  Type
     10objects can be handled using any of the :c:func:`PyObject_\*` or
     11:c:func:`PyType_\*` functions, but do not offer much that's interesting to most
    1212Python applications. These objects are fundamental to how objects behave, so
    1313they are very important to the interpreter itself and to any extension module
     
    2626cmpfunc, reprfunc, hashfunc
    2727
    28 The structure definition for :ctype:`PyTypeObject` can be found in
     28The structure definition for :c:type:`PyTypeObject` can be found in
    2929:file:`Include/object.h`.  For convenience of reference, this repeats the
    3030definition found there:
     
    3333
    3434
    35 The type object structure extends the :ctype:`PyVarObject` structure. The
     35The type object structure extends the :c:type:`PyVarObject` structure. The
    3636:attr:`ob_size` field is used for dynamic types (created by  :func:`type_new`,
    37 usually called from a class statement). Note that :cdata:`PyType_Type` (the
    38 metatype) initializes :attr:`tp_itemsize`, which means that its instances (i.e.
     37usually called from a class statement). Note that :c:data:`PyType_Type` (the
     38metatype) initializes :c:member:`~PyTypeObject.tp_itemsize`, which means that its instances (i.e.
    3939type objects) *must* have the :attr:`ob_size` field.
    4040
    4141
    42 .. cmember:: PyObject* PyObject._ob_next
     42.. c:member:: PyObject* PyObject._ob_next
    4343             PyObject* PyObject._ob_prev
    4444
     
    5555
    5656
    57 .. cmember:: Py_ssize_t PyObject.ob_refcnt
     57.. c:member:: Py_ssize_t PyObject.ob_refcnt
    5858
    5959   This is the type object's reference count, initialized to ``1`` by the
     
    6666
    6767   .. versionchanged:: 2.5
    68       This field used to be an :ctype:`int` type. This might require changes
     68      This field used to be an :c:type:`int` type. This might require changes
    6969      in your code for properly supporting 64-bit systems.
    7070
    7171
    72 .. cmember:: PyTypeObject* PyObject.ob_type
     72.. c:member:: PyTypeObject* PyObject.ob_type
    7373
    7474   This is the type's type, in other words its metatype.  It is initialized by the
     
    8484
    8585   This should be done before any instances of the type are created.
    86    :cfunc:`PyType_Ready` checks if :attr:`ob_type` is *NULL*, and if so,
     86   :c:func:`PyType_Ready` checks if :attr:`ob_type` is *NULL*, and if so,
    8787   initializes it: in Python 2.2, it is set to ``&PyType_Type``; in Python 2.2.1
    8888   and later it is initialized to the :attr:`ob_type` field of the base class.
    89    :cfunc:`PyType_Ready` will not change this field if it is non-zero.
     89   :c:func:`PyType_Ready` will not change this field if it is non-zero.
    9090
    9191   In Python 2.2, this field is not inherited by subtypes.  In 2.2.1, and in 2.3
     
    9393
    9494
    95 .. cmember:: Py_ssize_t PyVarObject.ob_size
     95.. c:member:: Py_ssize_t PyVarObject.ob_size
    9696
    9797   For statically allocated type objects, this should be initialized to zero.  For
     
    101101
    102102
    103 .. cmember:: char* PyTypeObject.tp_name
     103.. c:member:: char* PyTypeObject.tp_name
    104104
    105105   Pointer to a NUL-terminated string containing the name of the type. For types
     
    109109   full package name is part of the full module name.  For example, a type named
    110110   :class:`T` defined in module :mod:`M` in subpackage :mod:`Q` in package :mod:`P`
    111    should have the :attr:`tp_name` initializer ``"P.Q.M.T"``.
     111   should have the :c:member:`~PyTypeObject.tp_name` initializer ``"P.Q.M.T"``.
    112112
    113113   For dynamically allocated type objects, this should just be the type name, and
     
    120120   :attr:`__name__` attribute.
    121121
    122    If no dot is present, the entire :attr:`tp_name` field is made accessible as the
     122   If no dot is present, the entire :c:member:`~PyTypeObject.tp_name` field is made accessible as the
    123123   :attr:`__name__` attribute, and the :attr:`__module__` attribute is undefined
    124124   (unless explicitly set in the dictionary, as explained above).  This means your
     
    128128
    129129
    130 .. cmember:: Py_ssize_t PyTypeObject.tp_basicsize
     130.. c:member:: Py_ssize_t PyTypeObject.tp_basicsize
    131131             Py_ssize_t PyTypeObject.tp_itemsize
    132132
     
    134134
    135135   There are two kinds of types: types with fixed-length instances have a zero
    136    :attr:`tp_itemsize` field, types with variable-length instances have a non-zero
    137    :attr:`tp_itemsize` field.  For a type with fixed-length instances, all
    138    instances have the same size, given in :attr:`tp_basicsize`.
     136   :c:member:`~PyTypeObject.tp_itemsize` field, types with variable-length instances have a non-zero
     137   :c:member:`~PyTypeObject.tp_itemsize` field.  For a type with fixed-length instances, all
     138   instances have the same size, given in :c:member:`~PyTypeObject.tp_basicsize`.
    139139
    140140   For a type with variable-length instances, the instances must have an
    141    :attr:`ob_size` field, and the instance size is :attr:`tp_basicsize` plus N
    142    times :attr:`tp_itemsize`, where N is the "length" of the object.  The value of
     141   :attr:`ob_size` field, and the instance size is :c:member:`~PyTypeObject.tp_basicsize` plus N
     142   times :c:member:`~PyTypeObject.tp_itemsize`, where N is the "length" of the object.  The value of
    143143   N is typically stored in the instance's :attr:`ob_size` field.  There are
    144144   exceptions:  for example, long ints use a negative :attr:`ob_size` to indicate a
     
    150150
    151151   The basic size includes the fields in the instance declared by the macro
    152    :cmacro:`PyObject_HEAD` or :cmacro:`PyObject_VAR_HEAD` (whichever is used to
     152   :c:macro:`PyObject_HEAD` or :c:macro:`PyObject_VAR_HEAD` (whichever is used to
    153153   declare the instance struct) and this in turn includes the :attr:`_ob_prev` and
    154154   :attr:`_ob_next` fields if they are present.  This means that the only correct
    155    way to get an initializer for the :attr:`tp_basicsize` is to use the
     155   way to get an initializer for the :c:member:`~PyTypeObject.tp_basicsize` is to use the
    156156   ``sizeof`` operator on the struct used to declare the instance layout.
    157157   The basic size does not include the GC header size (this is new in Python 2.2;
    158    in 2.1 and 2.0, the GC header size was included in :attr:`tp_basicsize`).
     158   in 2.1 and 2.0, the GC header size was included in :c:member:`~PyTypeObject.tp_basicsize`).
    159159
    160160   These fields are inherited separately by subtypes.  If the base type has a
    161    non-zero :attr:`tp_itemsize`, it is generally not safe to set
    162    :attr:`tp_itemsize` to a different non-zero value in a subtype (though this
     161   non-zero :c:member:`~PyTypeObject.tp_itemsize`, it is generally not safe to set
     162   :c:member:`~PyTypeObject.tp_itemsize` to a different non-zero value in a subtype (though this
    163163   depends on the implementation of the base type).
    164164
    165165   A note about alignment: if the variable items require a particular alignment,
    166    this should be taken care of by the value of :attr:`tp_basicsize`.  Example:
    167    suppose a type implements an array of ``double``. :attr:`tp_itemsize` is
     166   this should be taken care of by the value of :c:member:`~PyTypeObject.tp_basicsize`.  Example:
     167   suppose a type implements an array of ``double``. :c:member:`~PyTypeObject.tp_itemsize` is
    168168   ``sizeof(double)``. It is the programmer's responsibility that
    169    :attr:`tp_basicsize` is a multiple of ``sizeof(double)`` (assuming this is the
     169   :c:member:`~PyTypeObject.tp_basicsize` is a multiple of ``sizeof(double)`` (assuming this is the
    170170   alignment requirement for ``double``).
    171171
    172172
    173 .. cmember:: destructor PyTypeObject.tp_dealloc
     173.. c:member:: destructor PyTypeObject.tp_dealloc
    174174
    175175   A pointer to the instance destructor function.  This function must be defined
     
    177177   the case for the singletons ``None`` and ``Ellipsis``).
    178178
    179    The destructor function is called by the :cfunc:`Py_DECREF` and
    180    :cfunc:`Py_XDECREF` macros when the new reference count is zero.  At this point,
     179   The destructor function is called by the :c:func:`Py_DECREF` and
     180   :c:func:`Py_XDECREF` macros when the new reference count is zero.  At this point,
    181181   the instance is still in existence, but there are no references to it.  The
    182182   destructor function should free all references which the instance owns, free all
    183183   memory buffers owned by the instance (using the freeing function corresponding
    184184   to the allocation function used to allocate the buffer), and finally (as its
    185    last action) call the type's :attr:`tp_free` function.  If the type is not
     185   last action) call the type's :c:member:`~PyTypeObject.tp_free` function.  If the type is not
    186186   subtypable (doesn't have the :const:`Py_TPFLAGS_BASETYPE` flag bit set), it is
    187187   permissible to call the object deallocator directly instead of via
    188    :attr:`tp_free`.  The object deallocator should be the one used to allocate the
    189    instance; this is normally :cfunc:`PyObject_Del` if the instance was allocated
    190    using :cfunc:`PyObject_New` or :cfunc:`PyObject_VarNew`, or
    191    :cfunc:`PyObject_GC_Del` if the instance was allocated using
    192    :cfunc:`PyObject_GC_New` or :cfunc:`PyObject_GC_VarNew`.
     188   :c:member:`~PyTypeObject.tp_free`.  The object deallocator should be the one used to allocate the
     189   instance; this is normally :c:func:`PyObject_Del` if the instance was allocated
     190   using :c:func:`PyObject_New` or :c:func:`PyObject_VarNew`, or
     191   :c:func:`PyObject_GC_Del` if the instance was allocated using
     192   :c:func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar`.
    193193
    194194   This field is inherited by subtypes.
    195195
    196196
    197 .. cmember:: printfunc PyTypeObject.tp_print
     197.. c:member:: printfunc PyTypeObject.tp_print
    198198
    199199   An optional pointer to the instance print function.
    200200
    201201   The print function is only called when the instance is printed to a *real* file;
    202    when it is printed to a pseudo-file (like a :class:`StringIO` instance), the
    203    instance's :attr:`tp_repr` or :attr:`tp_str` function is called to convert it to
    204    a string.  These are also called when the type's :attr:`tp_print` field is
    205    *NULL*.  A type should never implement :attr:`tp_print` in a way that produces
    206    different output than :attr:`tp_repr` or :attr:`tp_str` would.
    207 
    208    The print function is called with the same signature as :cfunc:`PyObject_Print`:
     202   when it is printed to a pseudo-file (like a :class:`~StringIO.StringIO` instance), the
     203   instance's :c:member:`~PyTypeObject.tp_repr` or :c:member:`~PyTypeObject.tp_str` function is called to convert it to
     204   a string.  These are also called when the type's :c:member:`~PyTypeObject.tp_print` field is
     205   *NULL*.  A type should never implement :c:member:`~PyTypeObject.tp_print` in a way that produces
     206   different output than :c:member:`~PyTypeObject.tp_repr` or :c:member:`~PyTypeObject.tp_str` would.
     207
     208   The print function is called with the same signature as :c:func:`PyObject_Print`:
    209209   ``int tp_print(PyObject *self, FILE *file, int flags)``.  The *self* argument is
    210210   the instance to be printed.  The *file* argument is the stdio file to which it
    211211   is to be printed.  The *flags* argument is composed of flag bits. The only flag
    212212   bit currently defined is :const:`Py_PRINT_RAW`. When the :const:`Py_PRINT_RAW`
    213    flag bit is set, the instance should be printed the same way as :attr:`tp_str`
     213   flag bit is set, the instance should be printed the same way as :c:member:`~PyTypeObject.tp_str`
    214214   would format it; when the :const:`Py_PRINT_RAW` flag bit is clear, the instance
    215    should be printed the same was as :attr:`tp_repr` would format it. It should
     215   should be printed the same was as :c:member:`~PyTypeObject.tp_repr` would format it. It should
    216216   return ``-1`` and set an exception condition when an error occurred during the
    217217   comparison.
    218218
    219    It is possible that the :attr:`tp_print` field will be deprecated. In any case,
    220    it is recommended not to define :attr:`tp_print`, but instead to rely on
    221    :attr:`tp_repr` and :attr:`tp_str` for printing.
     219   It is possible that the :c:member:`~PyTypeObject.tp_print` field will be deprecated. In any case,
     220   it is recommended not to define :c:member:`~PyTypeObject.tp_print`, but instead to rely on
     221   :c:member:`~PyTypeObject.tp_repr` and :c:member:`~PyTypeObject.tp_str` for printing.
    222222
    223223   This field is inherited by subtypes.
    224224
    225225
    226 .. cmember:: getattrfunc PyTypeObject.tp_getattr
     226.. c:member:: getattrfunc PyTypeObject.tp_getattr
    227227
    228228   An optional pointer to the get-attribute-string function.
    229229
    230230   This field is deprecated.  When it is defined, it should point to a function
    231    that acts the same as the :attr:`tp_getattro` function, but taking a C string
     231   that acts the same as the :c:member:`~PyTypeObject.tp_getattro` function, but taking a C string
    232232   instead of a Python string object to give the attribute name.  The signature is
    233    the same as for :cfunc:`PyObject_GetAttrString`.
    234 
    235    This field is inherited by subtypes together with :attr:`tp_getattro`: a subtype
    236    inherits both :attr:`tp_getattr` and :attr:`tp_getattro` from its base type when
    237    the subtype's :attr:`tp_getattr` and :attr:`tp_getattro` are both *NULL*.
    238 
    239 
    240 .. cmember:: setattrfunc PyTypeObject.tp_setattr
     233   the same as for :c:func:`PyObject_GetAttrString`.
     234
     235   This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_getattro`: a subtype
     236   inherits both :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` from its base type when
     237   the subtype's :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` are both *NULL*.
     238
     239
     240.. c:member:: setattrfunc PyTypeObject.tp_setattr
    241241
    242242   An optional pointer to the set-attribute-string function.
    243243
    244244   This field is deprecated.  When it is defined, it should point to a function
    245    that acts the same as the :attr:`tp_setattro` function, but taking a C string
     245   that acts the same as the :c:member:`~PyTypeObject.tp_setattro` function, but taking a C string
    246246   instead of a Python string object to give the attribute name.  The signature is
    247    the same as for :cfunc:`PyObject_SetAttrString`.
    248 
    249    This field is inherited by subtypes together with :attr:`tp_setattro`: a subtype
    250    inherits both :attr:`tp_setattr` and :attr:`tp_setattro` from its base type when
    251    the subtype's :attr:`tp_setattr` and :attr:`tp_setattro` are both *NULL*.
    252 
    253 
    254 .. cmember:: cmpfunc PyTypeObject.tp_compare
     247   the same as for :c:func:`PyObject_SetAttrString`.
     248
     249   This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_setattro`: a subtype
     250   inherits both :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` from its base type when
     251   the subtype's :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` are both *NULL*.
     252
     253
     254.. c:member:: cmpfunc PyTypeObject.tp_compare
    255255
    256256   An optional pointer to the three-way comparison function.
    257257
    258    The signature is the same as for :cfunc:`PyObject_Compare`. The function should
     258   The signature is the same as for :c:func:`PyObject_Compare`. The function should
    259259   return ``1`` if *self* greater than *other*, ``0`` if *self* is equal to
    260260   *other*, and ``-1`` if *self* less than *other*.  It should return ``-1`` and
    261261   set an exception condition when an error occurred during the comparison.
    262262
    263    This field is inherited by subtypes together with :attr:`tp_richcompare` and
    264    :attr:`tp_hash`: a subtypes inherits all three of :attr:`tp_compare`,
    265    :attr:`tp_richcompare`, and :attr:`tp_hash` when the subtype's
    266    :attr:`tp_compare`, :attr:`tp_richcompare`, and :attr:`tp_hash` are all *NULL*.
    267 
    268 
    269 .. cmember:: reprfunc PyTypeObject.tp_repr
     263   This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_richcompare` and
     264   :c:member:`~PyTypeObject.tp_hash`: a subtypes inherits all three of :c:member:`~PyTypeObject.tp_compare`,
     265   :c:member:`~PyTypeObject.tp_richcompare`, and :c:member:`~PyTypeObject.tp_hash` when the subtype's
     266   :c:member:`~PyTypeObject.tp_compare`, :c:member:`~PyTypeObject.tp_richcompare`, and :c:member:`~PyTypeObject.tp_hash` are all *NULL*.
     267
     268
     269.. c:member:: reprfunc PyTypeObject.tp_repr
    270270
    271271   .. index:: builtin: repr
     
    274274   :func:`repr`.
    275275
    276    The signature is the same as for :cfunc:`PyObject_Repr`; it must return a string
     276   The signature is the same as for :c:func:`PyObject_Repr`; it must return a string
    277277   or a Unicode object.  Ideally, this function should return a string that, when
    278278   passed to :func:`eval`, given a suitable environment, returns an object with the
     
    287287   This field is inherited by subtypes.
    288288
    289 .. cmember:: PyNumberMethods* tp_as_number
     289.. c:member:: PyNumberMethods* tp_as_number
    290290
    291291   Pointer to an additional structure that contains fields relevant only to
     
    293293   :ref:`number-structs`.
    294294
    295    The :attr:`tp_as_number` field is not inherited, but the contained fields are
     295   The :c:member:`~PyTypeObject.tp_as_number` field is not inherited, but the contained fields are
    296296   inherited individually.
    297297
    298298
    299 .. cmember:: PySequenceMethods* tp_as_sequence
     299.. c:member:: PySequenceMethods* tp_as_sequence
    300300
    301301   Pointer to an additional structure that contains fields relevant only to
     
    303303   in :ref:`sequence-structs`.
    304304
    305    The :attr:`tp_as_sequence` field is not inherited, but the contained fields
     305   The :c:member:`~PyTypeObject.tp_as_sequence` field is not inherited, but the contained fields
    306306   are inherited individually.
    307307
    308308
    309 .. cmember:: PyMappingMethods* tp_as_mapping
     309.. c:member:: PyMappingMethods* tp_as_mapping
    310310
    311311   Pointer to an additional structure that contains fields relevant only to
     
    313313   :ref:`mapping-structs`.
    314314
    315    The :attr:`tp_as_mapping` field is not inherited, but the contained fields
     315   The :c:member:`~PyTypeObject.tp_as_mapping` field is not inherited, but the contained fields
    316316   are inherited individually.
    317317
    318318
    319 .. cmember:: hashfunc PyTypeObject.tp_hash
     319.. c:member:: hashfunc PyTypeObject.tp_hash
    320320
    321321   .. index:: builtin: hash
     
    324324   :func:`hash`.
    325325
    326    The signature is the same as for :cfunc:`PyObject_Hash`; it must return a C
     326   The signature is the same as for :c:func:`PyObject_Hash`; it must return a C
    327327   long.  The value ``-1`` should not be returned as a normal return value; when an
    328328   error occurs during the computation of the hash value, the function should set
    329329   an exception and return ``-1``.
    330330
    331    This field can be set explicitly to :cfunc:`PyObject_HashNotImplemented` to
     331   This field can be set explicitly to :c:func:`PyObject_HashNotImplemented` to
    332332   block inheritance of the hash method from a parent type. This is interpreted
    333333   as the equivalent of ``__hash__ = None`` at the Python level, causing
     
    335335   that the converse is also true - setting ``__hash__ = None`` on a class at
    336336   the Python level will result in the ``tp_hash`` slot being set to
    337    :cfunc:`PyObject_HashNotImplemented`.
    338 
    339    When this field is not set, two possibilities exist: if the :attr:`tp_compare`
    340    and :attr:`tp_richcompare` fields are both *NULL*, a default hash value based on
     337   :c:func:`PyObject_HashNotImplemented`.
     338
     339   When this field is not set, two possibilities exist: if the :c:member:`~PyTypeObject.tp_compare`
     340   and :c:member:`~PyTypeObject.tp_richcompare` fields are both *NULL*, a default hash value based on
    341341   the object's address is returned; otherwise, a :exc:`TypeError` is raised.
    342342
    343    This field is inherited by subtypes together with :attr:`tp_richcompare` and
    344    :attr:`tp_compare`: a subtypes inherits all three of :attr:`tp_compare`,
    345    :attr:`tp_richcompare`, and :attr:`tp_hash`, when the subtype's
    346    :attr:`tp_compare`, :attr:`tp_richcompare` and :attr:`tp_hash` are all *NULL*.
    347 
    348 
    349 .. cmember:: ternaryfunc PyTypeObject.tp_call
     343   This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_richcompare` and
     344   :c:member:`~PyTypeObject.tp_compare`: a subtypes inherits all three of :c:member:`~PyTypeObject.tp_compare`,
     345   :c:member:`~PyTypeObject.tp_richcompare`, and :c:member:`~PyTypeObject.tp_hash`, when the subtype's
     346   :c:member:`~PyTypeObject.tp_compare`, :c:member:`~PyTypeObject.tp_richcompare` and :c:member:`~PyTypeObject.tp_hash` are all *NULL*.
     347
     348
     349.. c:member:: ternaryfunc PyTypeObject.tp_call
    350350
    351351   An optional pointer to a function that implements calling the object.  This
    352352   should be *NULL* if the object is not callable.  The signature is the same as
    353    for :cfunc:`PyObject_Call`.
     353   for :c:func:`PyObject_Call`.
    354354
    355355   This field is inherited by subtypes.
    356356
    357357
    358 .. cmember:: reprfunc PyTypeObject.tp_str
     358.. c:member:: reprfunc PyTypeObject.tp_str
    359359
    360360   An optional pointer to a function that implements the built-in operation
    361361   :func:`str`.  (Note that :class:`str` is a type now, and :func:`str` calls the
    362    constructor for that type.  This constructor calls :cfunc:`PyObject_Str` to do
    363    the actual work, and :cfunc:`PyObject_Str` will call this handler.)
    364 
    365    The signature is the same as for :cfunc:`PyObject_Str`; it must return a string
     362   constructor for that type.  This constructor calls :c:func:`PyObject_Str` to do
     363   the actual work, and :c:func:`PyObject_Str` will call this handler.)
     364
     365   The signature is the same as for :c:func:`PyObject_Str`; it must return a string
    366366   or a Unicode object.  This function should return a "friendly" string
    367367   representation of the object, as this is the representation that will be used by
    368368   the print statement.
    369369
    370    When this field is not set, :cfunc:`PyObject_Repr` is called to return a string
     370   When this field is not set, :c:func:`PyObject_Repr` is called to return a string
    371371   representation.
    372372
     
    374374
    375375
    376 .. cmember:: getattrofunc PyTypeObject.tp_getattro
     376.. c:member:: getattrofunc PyTypeObject.tp_getattro
    377377
    378378   An optional pointer to the get-attribute function.
    379379
    380    The signature is the same as for :cfunc:`PyObject_GetAttr`.  It is usually
    381    convenient to set this field to :cfunc:`PyObject_GenericGetAttr`, which
     380   The signature is the same as for :c:func:`PyObject_GetAttr`.  It is usually
     381   convenient to set this field to :c:func:`PyObject_GenericGetAttr`, which
    382382   implements the normal way of looking for object attributes.
    383383
    384    This field is inherited by subtypes together with :attr:`tp_getattr`: a subtype
    385    inherits both :attr:`tp_getattr` and :attr:`tp_getattro` from its base type when
    386    the subtype's :attr:`tp_getattr` and :attr:`tp_getattro` are both *NULL*.
    387 
    388 
    389 .. cmember:: setattrofunc PyTypeObject.tp_setattro
     384   This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_getattr`: a subtype
     385   inherits both :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` from its base type when
     386   the subtype's :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` are both *NULL*.
     387
     388
     389.. c:member:: setattrofunc PyTypeObject.tp_setattro
    390390
    391391   An optional pointer to the set-attribute function.
    392392
    393    The signature is the same as for :cfunc:`PyObject_SetAttr`.  It is usually
    394    convenient to set this field to :cfunc:`PyObject_GenericSetAttr`, which
     393   The signature is the same as for :c:func:`PyObject_SetAttr`.  It is usually
     394   convenient to set this field to :c:func:`PyObject_GenericSetAttr`, which
    395395   implements the normal way of setting object attributes.
    396396
    397    This field is inherited by subtypes together with :attr:`tp_setattr`: a subtype
    398    inherits both :attr:`tp_setattr` and :attr:`tp_setattro` from its base type when
    399    the subtype's :attr:`tp_setattr` and :attr:`tp_setattro` are both *NULL*.
    400 
    401 
    402 .. cmember:: PyBufferProcs* PyTypeObject.tp_as_buffer
     397   This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_setattr`: a subtype
     398   inherits both :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` from its base type when
     399   the subtype's :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` are both *NULL*.
     400
     401
     402.. c:member:: PyBufferProcs* PyTypeObject.tp_as_buffer
    403403
    404404   Pointer to an additional structure that contains fields relevant only to objects
     
    406406   :ref:`buffer-structs`.
    407407
    408    The :attr:`tp_as_buffer` field is not inherited, but the contained fields are
     408   The :c:member:`~PyTypeObject.tp_as_buffer` field is not inherited, but the contained fields are
    409409   inherited individually.
    410410
    411411
    412 .. cmember:: long PyTypeObject.tp_flags
     412.. c:member:: long PyTypeObject.tp_flags
    413413
    414414   This field is a bit mask of various flags.  Some flags indicate variant
    415415   semantics for certain situations; others are used to indicate that certain
    416416   fields in the type object (or in the extension structures referenced via
    417    :attr:`tp_as_number`, :attr:`tp_as_sequence`, :attr:`tp_as_mapping`, and
    418    :attr:`tp_as_buffer`) that were historically not always present are valid; if
     417   :c:member:`~PyTypeObject.tp_as_number`, :c:member:`~PyTypeObject.tp_as_sequence`, :c:member:`~PyTypeObject.tp_as_mapping`, and
     418   :c:member:`~PyTypeObject.tp_as_buffer`) that were historically not always present are valid; if
    419419   such a flag bit is clear, the type fields it guards must not be accessed and
    420420   must be considered to have a zero or *NULL* value instead.
     
    426426   the flag bit is copied into the subtype together with a pointer to the extension
    427427   structure.  The :const:`Py_TPFLAGS_HAVE_GC` flag bit is inherited together with
    428    the :attr:`tp_traverse` and :attr:`tp_clear` fields, i.e. if the
     428   the :c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` fields, i.e. if the
    429429   :const:`Py_TPFLAGS_HAVE_GC` flag bit is clear in the subtype and the
    430    :attr:`tp_traverse` and :attr:`tp_clear` fields in the subtype exist (as
     430   :c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` fields in the subtype exist (as
    431431   indicated by the :const:`Py_TPFLAGS_HAVE_RICHCOMPARE` flag bit) and have *NULL*
    432432   values.
    433433
    434434   The following bit masks are currently defined; these can be ORed together using
    435    the ``|`` operator to form the value of the :attr:`tp_flags` field.  The macro
    436    :cfunc:`PyType_HasFeature` takes a type and a flags value, *tp* and *f*, and
     435   the ``|`` operator to form the value of the :c:member:`~PyTypeObject.tp_flags` field.  The macro
     436   :c:func:`PyType_HasFeature` takes a type and a flags value, *tp* and *f*, and
    437437   checks whether ``tp->tp_flags & f`` is non-zero.
    438438
     
    440440   .. data:: Py_TPFLAGS_HAVE_GETCHARBUFFER
    441441
    442       If this bit is set, the :ctype:`PyBufferProcs` struct referenced by
    443       :attr:`tp_as_buffer` has the :attr:`bf_getcharbuffer` field.
     442      If this bit is set, the :c:type:`PyBufferProcs` struct referenced by
     443      :c:member:`~PyTypeObject.tp_as_buffer` has the :attr:`bf_getcharbuffer` field.
    444444
    445445
    446446   .. data:: Py_TPFLAGS_HAVE_SEQUENCE_IN
    447447
    448       If this bit is set, the :ctype:`PySequenceMethods` struct referenced by
    449       :attr:`tp_as_sequence` has the :attr:`sq_contains` field.
     448      If this bit is set, the :c:type:`PySequenceMethods` struct referenced by
     449      :c:member:`~PyTypeObject.tp_as_sequence` has the :attr:`sq_contains` field.
    450450
    451451
     
    458458   .. data:: Py_TPFLAGS_HAVE_INPLACEOPS
    459459
    460       If this bit is set, the :ctype:`PySequenceMethods` struct referenced by
    461       :attr:`tp_as_sequence` and the :ctype:`PyNumberMethods` structure referenced by
    462       :attr:`tp_as_number` contain the fields for in-place operators. In particular,
    463       this means that the :ctype:`PyNumberMethods` structure has the fields
     460      If this bit is set, the :c:type:`PySequenceMethods` struct referenced by
     461      :c:member:`~PyTypeObject.tp_as_sequence` and the :c:type:`PyNumberMethods` structure referenced by
     462      :c:member:`~PyTypeObject.tp_as_number` contain the fields for in-place operators. In particular,
     463      this means that the :c:type:`PyNumberMethods` structure has the fields
    464464      :attr:`nb_inplace_add`, :attr:`nb_inplace_subtract`,
    465465      :attr:`nb_inplace_multiply`, :attr:`nb_inplace_divide`,
     
    467467      :attr:`nb_inplace_lshift`, :attr:`nb_inplace_rshift`, :attr:`nb_inplace_and`,
    468468      :attr:`nb_inplace_xor`, and :attr:`nb_inplace_or`; and the
    469       :ctype:`PySequenceMethods` struct has the fields :attr:`sq_inplace_concat` and
     469      :c:type:`PySequenceMethods` struct has the fields :attr:`sq_inplace_concat` and
    470470      :attr:`sq_inplace_repeat`.
    471471
     
    474474
    475475      If this bit is set, the binary and ternary operations in the
    476       :ctype:`PyNumberMethods` structure referenced by :attr:`tp_as_number` accept
     476      :c:type:`PyNumberMethods` structure referenced by :c:member:`~PyTypeObject.tp_as_number` accept
    477477      arguments of arbitrary object types, and do their own type conversions if
    478478      needed.  If this bit is clear, those operations require that all arguments have
     
    486486   .. data:: Py_TPFLAGS_HAVE_RICHCOMPARE
    487487
    488       If this bit is set, the type object has the :attr:`tp_richcompare` field, as
    489       well as the :attr:`tp_traverse` and the :attr:`tp_clear` fields.
     488      If this bit is set, the type object has the :c:member:`~PyTypeObject.tp_richcompare` field, as
     489      well as the :c:member:`~PyTypeObject.tp_traverse` and the :c:member:`~PyTypeObject.tp_clear` fields.
    490490
    491491
    492492   .. data:: Py_TPFLAGS_HAVE_WEAKREFS
    493493
    494       If this bit is set, the :attr:`tp_weaklistoffset` field is defined.  Instances
    495       of a type are weakly referenceable if the type's :attr:`tp_weaklistoffset` field
     494      If this bit is set, the :c:member:`~PyTypeObject.tp_weaklistoffset` field is defined.  Instances
     495      of a type are weakly referenceable if the type's :c:member:`~PyTypeObject.tp_weaklistoffset` field
    496496      has a value greater than zero.
    497497
     
    499499   .. data:: Py_TPFLAGS_HAVE_ITER
    500500
    501       If this bit is set, the type object has the :attr:`tp_iter` and
    502       :attr:`tp_iternext` fields.
     501      If this bit is set, the type object has the :c:member:`~PyTypeObject.tp_iter` and
     502      :c:member:`~PyTypeObject.tp_iternext` fields.
    503503
    504504
     
    506506
    507507      If this bit is set, the type object has several new fields defined starting in
    508       Python 2.2: :attr:`tp_methods`, :attr:`tp_members`, :attr:`tp_getset`,
    509       :attr:`tp_base`, :attr:`tp_dict`, :attr:`tp_descr_get`, :attr:`tp_descr_set`,
    510       :attr:`tp_dictoffset`, :attr:`tp_init`, :attr:`tp_alloc`, :attr:`tp_new`,
    511       :attr:`tp_free`, :attr:`tp_is_gc`, :attr:`tp_bases`, :attr:`tp_mro`,
    512       :attr:`tp_cache`, :attr:`tp_subclasses`, and :attr:`tp_weaklist`.
     508      Python 2.2: :c:member:`~PyTypeObject.tp_methods`, :c:member:`~PyTypeObject.tp_members`, :c:member:`~PyTypeObject.tp_getset`,
     509      :c:member:`~PyTypeObject.tp_base`, :c:member:`~PyTypeObject.tp_dict`, :c:member:`~PyTypeObject.tp_descr_get`, :c:member:`~PyTypeObject.tp_descr_set`,
     510      :c:member:`~PyTypeObject.tp_dictoffset`, :c:member:`~PyTypeObject.tp_init`, :c:member:`~PyTypeObject.tp_alloc`, :c:member:`~PyTypeObject.tp_new`,
     511      :c:member:`~PyTypeObject.tp_free`, :c:member:`~PyTypeObject.tp_is_gc`, :c:member:`~PyTypeObject.tp_bases`, :c:member:`~PyTypeObject.tp_mro`,
     512      :c:member:`~PyTypeObject.tp_cache`, :c:member:`~PyTypeObject.tp_subclasses`, and :c:member:`~PyTypeObject.tp_weaklist`.
    513513
    514514
     
    533533
    534534      This bit is set when the type object has been fully initialized by
    535       :cfunc:`PyType_Ready`.
     535      :c:func:`PyType_Ready`.
    536536
    537537
    538538   .. data:: Py_TPFLAGS_READYING
    539539
    540       This bit is set while :cfunc:`PyType_Ready` is in the process of initializing
     540      This bit is set while :c:func:`PyType_Ready` is in the process of initializing
    541541      the type object.
    542542
     
    545545
    546546      This bit is set when the object supports garbage collection.  If this bit
    547       is set, instances must be created using :cfunc:`PyObject_GC_New` and
    548       destroyed using :cfunc:`PyObject_GC_Del`.  More information in section
     547      is set, instances must be created using :c:func:`PyObject_GC_New` and
     548      destroyed using :c:func:`PyObject_GC_Del`.  More information in section
    549549      :ref:`supporting-cycle-detection`.  This bit also implies that the
    550       GC-related fields :attr:`tp_traverse` and :attr:`tp_clear` are present in
     550      GC-related fields :c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` are present in
    551551      the type object; but those fields also exist when
    552552      :const:`Py_TPFLAGS_HAVE_GC` is clear but
     
    564564
    565565
    566 .. cmember:: char* PyTypeObject.tp_doc
     566.. c:member:: char* PyTypeObject.tp_doc
    567567
    568568   An optional pointer to a NUL-terminated C string giving the docstring for this
     
    576576
    577577
    578 .. cmember:: traverseproc PyTypeObject.tp_traverse
     578.. c:member:: traverseproc PyTypeObject.tp_traverse
    579579
    580580   An optional pointer to a traversal function for the garbage collector.  This is
     
    583583   :ref:`supporting-cycle-detection`.
    584584
    585    The :attr:`tp_traverse` pointer is used by the garbage collector to detect
    586    reference cycles. A typical implementation of a :attr:`tp_traverse` function
    587    simply calls :cfunc:`Py_VISIT` on each of the instance's members that are Python
    588    objects.  For example, this is function :cfunc:`local_traverse` from the
     585   The :c:member:`~PyTypeObject.tp_traverse` pointer is used by the garbage collector to detect
     586   reference cycles. A typical implementation of a :c:member:`~PyTypeObject.tp_traverse` function
     587   simply calls :c:func:`Py_VISIT` on each of the instance's members that are Python
     588   objects.  For example, this is function :c:func:`local_traverse` from the
    589589   :mod:`thread` extension module::
    590590
     
    598598      }
    599599
    600    Note that :cfunc:`Py_VISIT` is called only on those members that can participate
     600   Note that :c:func:`Py_VISIT` is called only on those members that can participate
    601601   in reference cycles.  Although there is also a ``self->key`` member, it can only
    602602   be *NULL* or a Python string and therefore cannot be part of a reference cycle.
     
    604604   On the other hand, even if you know a member can never be part of a cycle, as a
    605605   debugging aid you may want to visit it anyway just so the :mod:`gc` module's
    606    :func:`get_referents` function will include it.
    607 
    608    Note that :cfunc:`Py_VISIT` requires the *visit* and *arg* parameters to
    609    :cfunc:`local_traverse` to have these specific names; don't name them just
     606   :func:`~gc.get_referents` function will include it.
     607
     608   Note that :c:func:`Py_VISIT` requires the *visit* and *arg* parameters to
     609   :c:func:`local_traverse` to have these specific names; don't name them just
    610610   anything.
    611611
    612    This field is inherited by subtypes together with :attr:`tp_clear` and the
    613    :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :attr:`tp_traverse`, and
    614    :attr:`tp_clear` are all inherited from the base type if they are all zero in
     612   This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_clear` and the
     613   :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :c:member:`~PyTypeObject.tp_traverse`, and
     614   :c:member:`~PyTypeObject.tp_clear` are all inherited from the base type if they are all zero in
    615615   the subtype *and* the subtype has the :const:`Py_TPFLAGS_HAVE_RICHCOMPARE` flag
    616616   bit set.
    617617
    618618
    619 .. cmember:: inquiry PyTypeObject.tp_clear
     619.. c:member:: inquiry PyTypeObject.tp_clear
    620620
    621621   An optional pointer to a clear function for the garbage collector. This is only
    622622   used if the :const:`Py_TPFLAGS_HAVE_GC` flag bit is set.
    623623
    624    The :attr:`tp_clear` member function is used to break reference cycles in cyclic
    625    garbage detected by the garbage collector.  Taken together, all :attr:`tp_clear`
     624   The :c:member:`~PyTypeObject.tp_clear` member function is used to break reference cycles in cyclic
     625   garbage detected by the garbage collector.  Taken together, all :c:member:`~PyTypeObject.tp_clear`
    626626   functions in the system must combine to break all reference cycles.  This is
    627    subtle, and if in any doubt supply a :attr:`tp_clear` function.  For example,
    628    the tuple type does not implement a :attr:`tp_clear` function, because it's
     627   subtle, and if in any doubt supply a :c:member:`~PyTypeObject.tp_clear` function.  For example,
     628   the tuple type does not implement a :c:member:`~PyTypeObject.tp_clear` function, because it's
    629629   possible to prove that no reference cycle can be composed entirely of tuples.
    630    Therefore the :attr:`tp_clear` functions of other types must be sufficient to
     630   Therefore the :c:member:`~PyTypeObject.tp_clear` functions of other types must be sufficient to
    631631   break any cycle containing a tuple.  This isn't immediately obvious, and there's
    632    rarely a good reason to avoid implementing :attr:`tp_clear`.
    633 
    634    Implementations of :attr:`tp_clear` should drop the instance's references to
     632   rarely a good reason to avoid implementing :c:member:`~PyTypeObject.tp_clear`.
     633
     634   Implementations of :c:member:`~PyTypeObject.tp_clear` should drop the instance's references to
    635635   those of its members that may be Python objects, and set its pointers to those
    636636   members to *NULL*, as in the following example::
     
    646646      }
    647647
    648    The :cfunc:`Py_CLEAR` macro should be used, because clearing references is
     648   The :c:func:`Py_CLEAR` macro should be used, because clearing references is
    649649   delicate:  the reference to the contained object must not be decremented until
    650650   after the pointer to the contained object is set to *NULL*.  This is because
     
    655655   it's important that the pointer to the contained object be *NULL* at that time,
    656656   so that *self* knows the contained object can no longer be used.  The
    657    :cfunc:`Py_CLEAR` macro performs the operations in a safe order.
    658 
    659    Because the goal of :attr:`tp_clear` functions is to break reference cycles,
     657   :c:func:`Py_CLEAR` macro performs the operations in a safe order.
     658
     659   Because the goal of :c:member:`~PyTypeObject.tp_clear` functions is to break reference cycles,
    660660   it's not necessary to clear contained objects like Python strings or Python
    661661   integers, which can't participate in reference cycles. On the other hand, it may
    662662   be convenient to clear all contained Python objects, and write the type's
    663    :attr:`tp_dealloc` function to invoke :attr:`tp_clear`.
     663   :c:member:`~PyTypeObject.tp_dealloc` function to invoke :c:member:`~PyTypeObject.tp_clear`.
    664664
    665665   More information about Python's garbage collection scheme can be found in
    666666   section :ref:`supporting-cycle-detection`.
    667667
    668    This field is inherited by subtypes together with :attr:`tp_traverse` and the
    669    :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :attr:`tp_traverse`, and
    670    :attr:`tp_clear` are all inherited from the base type if they are all zero in
     668   This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_traverse` and the
     669   :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :c:member:`~PyTypeObject.tp_traverse`, and
     670   :c:member:`~PyTypeObject.tp_clear` are all inherited from the base type if they are all zero in
    671671   the subtype *and* the subtype has the :const:`Py_TPFLAGS_HAVE_RICHCOMPARE` flag
    672672   bit set.
    673673
    674674
    675 .. cmember:: richcmpfunc PyTypeObject.tp_richcompare
     675.. c:member:: richcmpfunc PyTypeObject.tp_richcompare
    676676
    677677   An optional pointer to the rich comparison function, whose signature is
     
    689689      friends), directly raise :exc:`TypeError` in the rich comparison function.
    690690
    691    This field is inherited by subtypes together with :attr:`tp_compare` and
    692    :attr:`tp_hash`: a subtype inherits all three of :attr:`tp_compare`,
    693    :attr:`tp_richcompare`, and :attr:`tp_hash`, when the subtype's
    694    :attr:`tp_compare`, :attr:`tp_richcompare`, and :attr:`tp_hash` are all *NULL*.
     691   This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_compare` and
     692   :c:member:`~PyTypeObject.tp_hash`: a subtype inherits all three of :c:member:`~PyTypeObject.tp_compare`,
     693   :c:member:`~PyTypeObject.tp_richcompare`, and :c:member:`~PyTypeObject.tp_hash`, when the subtype's
     694   :c:member:`~PyTypeObject.tp_compare`, :c:member:`~PyTypeObject.tp_richcompare`, and :c:member:`~PyTypeObject.tp_hash` are all *NULL*.
    695695
    696696   The following constants are defined to be used as the third argument for
    697    :attr:`tp_richcompare` and for :cfunc:`PyObject_RichCompare`:
     697   :c:member:`~PyTypeObject.tp_richcompare` and for :c:func:`PyObject_RichCompare`:
    698698
    699699   +----------------+------------+
     
    717717set.
    718718
    719 .. cmember:: long PyTypeObject.tp_weaklistoffset
     719.. c:member:: long PyTypeObject.tp_weaklistoffset
    720720
    721721   If the instances of this type are weakly referenceable, this field is greater
    722722   than zero and contains the offset in the instance structure of the weak
    723723   reference list head (ignoring the GC header, if present); this offset is used by
    724    :cfunc:`PyObject_ClearWeakRefs` and the :cfunc:`PyWeakref_\*` functions.  The
    725    instance structure needs to include a field of type :ctype:`PyObject\*` which is
     724   :c:func:`PyObject_ClearWeakRefs` and the :c:func:`PyWeakref_\*` functions.  The
     725   instance structure needs to include a field of type :c:type:`PyObject\*` which is
    726726   initialized to *NULL*.
    727727
    728    Do not confuse this field with :attr:`tp_weaklist`; that is the list head for
     728   Do not confuse this field with :c:member:`~PyTypeObject.tp_weaklist`; that is the list head for
    729729   weak references to the type object itself.
    730730
     
    732732   may override this offset; this means that the subtype uses a different weak
    733733   reference list head than the base type.  Since the list head is always found via
    734    :attr:`tp_weaklistoffset`, this should not be a problem.
    735 
    736    When a type defined by a class statement has no :attr:`__slots__` declaration,
     734   :c:member:`~PyTypeObject.tp_weaklistoffset`, this should not be a problem.
     735
     736   When a type defined by a class statement has no :attr:`~object.__slots__` declaration,
    737737   and none of its base types are weakly referenceable, the type is made weakly
    738738   referenceable by adding a weak reference list head slot to the instance layout
    739    and setting the :attr:`tp_weaklistoffset` of that slot's offset.
     739   and setting the :c:member:`~PyTypeObject.tp_weaklistoffset` of that slot's offset.
    740740
    741741   When a type's :attr:`__slots__` declaration contains a slot named
    742742   :attr:`__weakref__`, that slot becomes the weak reference list head for
    743743   instances of the type, and the slot's offset is stored in the type's
    744    :attr:`tp_weaklistoffset`.
     744   :c:member:`~PyTypeObject.tp_weaklistoffset`.
    745745
    746746   When a type's :attr:`__slots__` declaration does not contain a slot named
    747    :attr:`__weakref__`, the type inherits its :attr:`tp_weaklistoffset` from its
     747   :attr:`__weakref__`, the type inherits its :c:member:`~PyTypeObject.tp_weaklistoffset` from its
    748748   base type.
    749749
     
    752752
    753753
    754 .. cmember:: getiterfunc PyTypeObject.tp_iter
     754.. c:member:: getiterfunc PyTypeObject.tp_iter
    755755
    756756   An optional pointer to a function that returns an iterator for the object.  Its
     
    759759   have this function, even if they don't define an :meth:`__iter__` method).
    760760
    761    This function has the same signature as :cfunc:`PyObject_GetIter`.
     761   This function has the same signature as :c:func:`PyObject_GetIter`.
    762762
    763763   This field is inherited by subtypes.
    764764
    765765
    766 .. cmember:: iternextfunc PyTypeObject.tp_iternext
     766.. c:member:: iternextfunc PyTypeObject.tp_iternext
    767767
    768768   An optional pointer to a function that returns the next item in an iterator.
     
    773773   they don't define a :meth:`next` method).
    774774
    775    Iterator types should also define the :attr:`tp_iter` function, and that
     775   Iterator types should also define the :c:member:`~PyTypeObject.tp_iter` function, and that
    776776   function should return the iterator instance itself (not a new iterator
    777777   instance).
    778778
    779    This function has the same signature as :cfunc:`PyIter_Next`.
     779   This function has the same signature as :c:func:`PyIter_Next`.
    780780
    781781   This field is inherited by subtypes.
    782782
    783 The next fields, up to and including :attr:`tp_weaklist`, only exist if the
     783The next fields, up to and including :c:member:`~PyTypeObject.tp_weaklist`, only exist if the
    784784:const:`Py_TPFLAGS_HAVE_CLASS` flag bit is set.
    785785
    786786
    787 .. cmember:: struct PyMethodDef* PyTypeObject.tp_methods
    788 
    789    An optional pointer to a static *NULL*-terminated array of :ctype:`PyMethodDef`
     787.. c:member:: struct PyMethodDef* PyTypeObject.tp_methods
     788
     789   An optional pointer to a static *NULL*-terminated array of :c:type:`PyMethodDef`
    790790   structures, declaring regular methods of this type.
    791791
    792792   For each entry in the array, an entry is added to the type's dictionary (see
    793    :attr:`tp_dict` below) containing a method descriptor.
     793   :c:member:`~PyTypeObject.tp_dict` below) containing a method descriptor.
    794794
    795795   This field is not inherited by subtypes (methods are inherited through a
     
    797797
    798798
    799 .. cmember:: struct PyMemberDef* PyTypeObject.tp_members
    800 
    801    An optional pointer to a static *NULL*-terminated array of :ctype:`PyMemberDef`
     799.. c:member:: struct PyMemberDef* PyTypeObject.tp_members
     800
     801   An optional pointer to a static *NULL*-terminated array of :c:type:`PyMemberDef`
    802802   structures, declaring regular data members (fields or slots) of instances of
    803803   this type.
    804804
    805805   For each entry in the array, an entry is added to the type's dictionary (see
    806    :attr:`tp_dict` below) containing a member descriptor.
     806   :c:member:`~PyTypeObject.tp_dict` below) containing a member descriptor.
    807807
    808808   This field is not inherited by subtypes (members are inherited through a
     
    810810
    811811
    812 .. cmember:: struct PyGetSetDef* PyTypeObject.tp_getset
    813 
    814    An optional pointer to a static *NULL*-terminated array of :ctype:`PyGetSetDef`
     812.. c:member:: struct PyGetSetDef* PyTypeObject.tp_getset
     813
     814   An optional pointer to a static *NULL*-terminated array of :c:type:`PyGetSetDef`
    815815   structures, declaring computed attributes of instances of this type.
    816816
    817817   For each entry in the array, an entry is added to the type's dictionary (see
    818    :attr:`tp_dict` below) containing a getset descriptor.
     818   :c:member:`~PyTypeObject.tp_dict` below) containing a getset descriptor.
    819819
    820820   This field is not inherited by subtypes (computed attributes are inherited
    821821   through a different mechanism).
    822822
    823    Docs for PyGetSetDef (XXX belong elsewhere)::
     823   .. XXX belongs elsewhere
     824
     825   Docs for PyGetSetDef::
    824826
    825827      typedef PyObject *(*getter)(PyObject *, void *);
     
    835837
    836838
    837 .. cmember:: PyTypeObject* PyTypeObject.tp_base
     839.. c:member:: PyTypeObject* PyTypeObject.tp_base
    838840
    839841   An optional pointer to a base type from which type properties are inherited.  At
     
    846848
    847849
    848 .. cmember:: PyObject* PyTypeObject.tp_dict
    849 
    850    The type's dictionary is stored here by :cfunc:`PyType_Ready`.
     850.. c:member:: PyObject* PyTypeObject.tp_dict
     851
     852   The type's dictionary is stored here by :c:func:`PyType_Ready`.
    851853
    852854   This field should normally be initialized to *NULL* before PyType_Ready is
    853855   called; it may also be initialized to a dictionary containing initial attributes
    854    for the type.  Once :cfunc:`PyType_Ready` has initialized the type, extra
     856   for the type.  Once :c:func:`PyType_Ready` has initialized the type, extra
    855857   attributes for the type may be added to this dictionary only if they don't
    856858   correspond to overloaded operations (like :meth:`__add__`).
     
    860862
    861863
    862 .. cmember:: descrgetfunc PyTypeObject.tp_descr_get
     864.. c:member:: descrgetfunc PyTypeObject.tp_descr_get
    863865
    864866   An optional pointer to a "descriptor get" function.
     
    868870      PyObject * tp_descr_get(PyObject *self, PyObject *obj, PyObject *type);
    869871
    870    XXX explain.
     872   .. XXX explain.
    871873
    872874   This field is inherited by subtypes.
    873875
    874876
    875 .. cmember:: descrsetfunc PyTypeObject.tp_descr_set
     877.. c:member:: descrsetfunc PyTypeObject.tp_descr_set
    876878
    877879   An optional pointer to a "descriptor set" function.
     
    883885   This field is inherited by subtypes.
    884886
    885    XXX explain.
    886 
    887 
    888 .. cmember:: long PyTypeObject.tp_dictoffset
     887   .. XXX explain.
     888
     889
     890.. c:member:: long PyTypeObject.tp_dictoffset
    889891
    890892   If the instances of this type have a dictionary containing instance variables,
    891893   this field is non-zero and contains the offset in the instances of the type of
    892894   the instance variable dictionary; this offset is used by
    893    :cfunc:`PyObject_GenericGetAttr`.
    894 
    895    Do not confuse this field with :attr:`tp_dict`; that is the dictionary for
     895   :c:func:`PyObject_GenericGetAttr`.
     896
     897   Do not confuse this field with :c:member:`~PyTypeObject.tp_dict`; that is the dictionary for
    896898   attributes of the type object itself.
    897899
     
    902904   structure contains a variable-length part.  This is used for example to add an
    903905   instance variable dictionary to subtypes of :class:`str` or :class:`tuple`. Note
    904    that the :attr:`tp_basicsize` field should account for the dictionary added to
     906   that the :c:member:`~PyTypeObject.tp_basicsize` field should account for the dictionary added to
    905907   the end in that case, even though the dictionary is not included in the basic
    906908   object layout.  On a system with a pointer size of 4 bytes,
    907    :attr:`tp_dictoffset` should be set to ``-4`` to indicate that the dictionary is
     909   :c:member:`~PyTypeObject.tp_dictoffset` should be set to ``-4`` to indicate that the dictionary is
    908910   at the very end of the structure.
    909911
    910912   The real dictionary offset in an instance can be computed from a negative
    911    :attr:`tp_dictoffset` as follows::
     913   :c:member:`~PyTypeObject.tp_dictoffset` as follows::
    912914
    913915      dictoffset = tp_basicsize + abs(ob_size)*tp_itemsize + tp_dictoffset
     
    915917          round up to sizeof(void*)
    916918
    917    where :attr:`tp_basicsize`, :attr:`tp_itemsize` and :attr:`tp_dictoffset` are
     919   where :c:member:`~PyTypeObject.tp_basicsize`, :c:member:`~PyTypeObject.tp_itemsize` and :c:member:`~PyTypeObject.tp_dictoffset` are
    918920   taken from the type object, and :attr:`ob_size` is taken from the instance.  The
    919921   absolute value is taken because long ints use the sign of :attr:`ob_size` to
    920922   store the sign of the number.  (There's never a need to do this calculation
    921    yourself; it is done for you by :cfunc:`_PyObject_GetDictPtr`.)
     923   yourself; it is done for you by :c:func:`_PyObject_GetDictPtr`.)
    922924
    923925   This field is inherited by subtypes, but see the rules listed below. A subtype
    924926   may override this offset; this means that the subtype instances store the
    925927   dictionary at a difference offset than the base type.  Since the dictionary is
    926    always found via :attr:`tp_dictoffset`, this should not be a problem.
    927 
    928    When a type defined by a class statement has no :attr:`__slots__` declaration,
     928   always found via :c:member:`~PyTypeObject.tp_dictoffset`, this should not be a problem.
     929
     930   When a type defined by a class statement has no :attr:`~object.__slots__` declaration,
    929931   and none of its base types has an instance variable dictionary, a dictionary
    930    slot is added to the instance layout and the :attr:`tp_dictoffset` is set to
     932   slot is added to the instance layout and the :c:member:`~PyTypeObject.tp_dictoffset` is set to
    931933   that slot's offset.
    932934
    933935   When a type defined by a class statement has a :attr:`__slots__` declaration,
    934    the type inherits its :attr:`tp_dictoffset` from its base type.
    935 
    936    (Adding a slot named :attr:`__dict__` to the :attr:`__slots__` declaration does
     936   the type inherits its :c:member:`~PyTypeObject.tp_dictoffset` from its base type.
     937
     938   (Adding a slot named :attr:`~object.__dict__` to the :attr:`__slots__` declaration does
    937939   not have the expected effect, it just causes confusion.  Maybe this should be
    938940   added as a feature just like :attr:`__weakref__` though.)
    939941
    940942
    941 .. cmember:: initproc PyTypeObject.tp_init
     943.. c:member:: initproc PyTypeObject.tp_init
    942944
    943945   An optional pointer to an instance initialization function.
     
    956958   :meth:`__init__`.
    957959
    958    The :attr:`tp_init` function, if not *NULL*, is called when an instance is
    959    created normally by calling its type, after the type's :attr:`tp_new` function
    960    has returned an instance of the type.  If the :attr:`tp_new` function returns an
     960   The :c:member:`~PyTypeObject.tp_init` function, if not *NULL*, is called when an instance is
     961   created normally by calling its type, after the type's :c:member:`~PyTypeObject.tp_new` function
     962   has returned an instance of the type.  If the :c:member:`~PyTypeObject.tp_new` function returns an
    961963   instance of some other type that is not a subtype of the original type, no
    962    :attr:`tp_init` function is called; if :attr:`tp_new` returns an instance of a
    963    subtype of the original type, the subtype's :attr:`tp_init` is called.  (VERSION
     964   :c:member:`~PyTypeObject.tp_init` function is called; if :c:member:`~PyTypeObject.tp_new` returns an instance of a
     965   subtype of the original type, the subtype's :c:member:`~PyTypeObject.tp_init` is called.  (VERSION
    964966   NOTE: described here is what is implemented in Python 2.2.1 and later.  In
    965    Python 2.2, the :attr:`tp_init` of the type of the object returned by
    966    :attr:`tp_new` was always called, if not *NULL*.)
     967   Python 2.2, the :c:member:`~PyTypeObject.tp_init` of the type of the object returned by
     968   :c:member:`~PyTypeObject.tp_new` was always called, if not *NULL*.)
    967969
    968970   This field is inherited by subtypes.
    969971
    970972
    971 .. cmember:: allocfunc PyTypeObject.tp_alloc
     973.. c:member:: allocfunc PyTypeObject.tp_alloc
    972974
    973975   An optional pointer to an instance allocation function.
     
    981983   length for the instance, suitably aligned, and initialized to zeros, but with
    982984   :attr:`ob_refcnt` set to ``1`` and :attr:`ob_type` set to the type argument.  If
    983    the type's :attr:`tp_itemsize` is non-zero, the object's :attr:`ob_size` field
     985   the type's :c:member:`~PyTypeObject.tp_itemsize` is non-zero, the object's :attr:`ob_size` field
    984986   should be initialized to *nitems* and the length of the allocated memory block
    985987   should be ``tp_basicsize + nitems*tp_itemsize``, rounded up to a multiple of
    986988   ``sizeof(void*)``; otherwise, *nitems* is not used and the length of the block
    987    should be :attr:`tp_basicsize`.
     989   should be :c:member:`~PyTypeObject.tp_basicsize`.
    988990
    989991   Do not use this function to do any other instance initialization, not even to
    990    allocate additional memory; that should be done by :attr:`tp_new`.
     992   allocate additional memory; that should be done by :c:member:`~PyTypeObject.tp_new`.
    991993
    992994   This field is inherited by static subtypes, but not by dynamic subtypes
    993995   (subtypes created by a class statement); in the latter, this field is always set
    994    to :cfunc:`PyType_GenericAlloc`, to force a standard heap allocation strategy.
     996   to :c:func:`PyType_GenericAlloc`, to force a standard heap allocation strategy.
    995997   That is also the recommended value for statically defined types.
    996998
    997999
    998 .. cmember:: newfunc PyTypeObject.tp_new
     1000.. c:member:: newfunc PyTypeObject.tp_new
    9991001
    10001002   An optional pointer to an instance creation function.
     
    10101012   The subtype argument is the type of the object being created; the *args* and
    10111013   *kwds* arguments represent positional and keyword arguments of the call to the
    1012    type.  Note that subtype doesn't have to equal the type whose :attr:`tp_new`
     1014   type.  Note that subtype doesn't have to equal the type whose :c:member:`~PyTypeObject.tp_new`
    10131015   function is called; it may be a subtype of that type (but not an unrelated
    10141016   type).
    10151017
    1016    The :attr:`tp_new` function should call ``subtype->tp_alloc(subtype, nitems)``
     1018   The :c:member:`~PyTypeObject.tp_new` function should call ``subtype->tp_alloc(subtype, nitems)``
    10171019   to allocate space for the object, and then do only as much further
    10181020   initialization as is absolutely necessary.  Initialization that can safely be
    1019    ignored or repeated should be placed in the :attr:`tp_init` handler.  A good
     1021   ignored or repeated should be placed in the :c:member:`~PyTypeObject.tp_init` handler.  A good
    10201022   rule of thumb is that for immutable types, all initialization should take place
    1021    in :attr:`tp_new`, while for mutable types, most initialization should be
    1022    deferred to :attr:`tp_init`.
     1023   in :c:member:`~PyTypeObject.tp_new`, while for mutable types, most initialization should be
     1024   deferred to :c:member:`~PyTypeObject.tp_init`.
    10231025
    10241026   This field is inherited by subtypes, except it is not inherited by static types
    1025    whose :attr:`tp_base` is *NULL* or ``&PyBaseObject_Type``.  The latter exception
     1027   whose :c:member:`~PyTypeObject.tp_base` is *NULL* or ``&PyBaseObject_Type``.  The latter exception
    10261028   is a precaution so that old extension types don't become callable simply by
    10271029   being linked with Python 2.2.
    10281030
    10291031
    1030 .. cmember:: destructor PyTypeObject.tp_free
     1032.. c:member:: destructor PyTypeObject.tp_free
    10311033
    10321034   An optional pointer to an instance deallocation function.
    10331035
    10341036   The signature of this function has changed slightly: in Python 2.2 and 2.2.1,
    1035    its signature is :ctype:`destructor`::
     1037   its signature is :c:type:`destructor`::
    10361038
    10371039      void tp_free(PyObject *)
    10381040
    1039    In Python 2.3 and beyond, its signature is :ctype:`freefunc`::
     1041   In Python 2.3 and beyond, its signature is :c:type:`freefunc`::
    10401042
    10411043      void tp_free(void *)
     
    10461048   This field is inherited by static subtypes, but not by dynamic subtypes
    10471049   (subtypes created by a class statement); in the latter, this field is set to a
    1048    deallocator suitable to match :cfunc:`PyType_GenericAlloc` and the value of the
     1050   deallocator suitable to match :c:func:`PyType_GenericAlloc` and the value of the
    10491051   :const:`Py_TPFLAGS_HAVE_GC` flag bit.
    10501052
    10511053
    1052 .. cmember:: inquiry PyTypeObject.tp_is_gc
     1054.. c:member:: inquiry PyTypeObject.tp_is_gc
    10531055
    10541056   An optional pointer to a function called by the garbage collector.
     
    10561058   The garbage collector needs to know whether a particular object is collectible
    10571059   or not.  Normally, it is sufficient to look at the object's type's
    1058    :attr:`tp_flags` field, and check the :const:`Py_TPFLAGS_HAVE_GC` flag bit.  But
     1060   :c:member:`~PyTypeObject.tp_flags` field, and check the :const:`Py_TPFLAGS_HAVE_GC` flag bit.  But
    10591061   some types have a mixture of statically and dynamically allocated instances, and
    10601062   the statically allocated instances are not collectible.  Such types should
     
    10651067
    10661068   (The only example of this are types themselves.  The metatype,
    1067    :cdata:`PyType_Type`, defines this function to distinguish between statically
     1069   :c:data:`PyType_Type`, defines this function to distinguish between statically
    10681070   and dynamically allocated types.)
    10691071
     
    10721074
    10731075
    1074 .. cmember:: PyObject* PyTypeObject.tp_bases
     1076.. c:member:: PyObject* PyTypeObject.tp_bases
    10751077
    10761078   Tuple of base types.
     
    10821084
    10831085
    1084 .. cmember:: PyObject* PyTypeObject.tp_mro
     1086.. c:member:: PyObject* PyTypeObject.tp_mro
    10851087
    10861088   Tuple containing the expanded set of base types, starting with the type itself
    10871089   and ending with :class:`object`, in Method Resolution Order.
    10881090
    1089    This field is not inherited; it is calculated fresh by :cfunc:`PyType_Ready`.
    1090 
    1091 
    1092 .. cmember:: PyObject* PyTypeObject.tp_cache
     1091   This field is not inherited; it is calculated fresh by :c:func:`PyType_Ready`.
     1092
     1093
     1094.. c:member:: PyObject* PyTypeObject.tp_cache
    10931095
    10941096   Unused.  Not inherited.  Internal use only.
    10951097
    10961098
    1097 .. cmember:: PyObject* PyTypeObject.tp_subclasses
     1099.. c:member:: PyObject* PyTypeObject.tp_subclasses
    10981100
    10991101   List of weak references to subclasses.  Not inherited.  Internal use only.
    11001102
    11011103
    1102 .. cmember:: PyObject* PyTypeObject.tp_weaklist
     1104.. c:member:: PyObject* PyTypeObject.tp_weaklist
    11031105
    11041106   Weak reference list head, for weak references to this type object.  Not
     
    11111113
    11121114
    1113 .. cmember:: Py_ssize_t PyTypeObject.tp_allocs
     1115.. c:member:: Py_ssize_t PyTypeObject.tp_allocs
    11141116
    11151117   Number of allocations.
    11161118
    11171119
    1118 .. cmember:: Py_ssize_t PyTypeObject.tp_frees
     1120.. c:member:: Py_ssize_t PyTypeObject.tp_frees
    11191121
    11201122   Number of frees.
    11211123
    11221124
    1123 .. cmember:: Py_ssize_t PyTypeObject.tp_maxalloc
     1125.. c:member:: Py_ssize_t PyTypeObject.tp_maxalloc
    11241126
    11251127   Maximum simultaneously allocated objects.
    11261128
    11271129
    1128 .. cmember:: PyTypeObject* PyTypeObject.tp_next
    1129 
    1130    Pointer to the next type object with a non-zero :attr:`tp_allocs` field.
     1130.. c:member:: PyTypeObject* PyTypeObject.tp_next
     1131
     1132   Pointer to the next type object with a non-zero :c:member:`~PyTypeObject.tp_allocs` field.
    11311133
    11321134Also, note that, in a garbage collected Python, tp_dealloc may be called from
     
    11491151
    11501152
    1151 .. ctype:: PyNumberMethods
     1153.. c:type:: PyNumberMethods
    11521154
    11531155   This structure holds pointers to the functions which an object uses to
     
    12141216  arguments:
    12151217
    1216   .. cmember:: coercion PyNumberMethods.nb_coerce
    1217 
    1218      This function is used by :cfunc:`PyNumber_CoerceEx` and has the same
     1218  .. c:member:: coercion PyNumberMethods.nb_coerce
     1219
     1220     This function is used by :c:func:`PyNumber_CoerceEx` and has the same
    12191221     signature.  The first argument is always a pointer to an object of the
    12201222     defined type.  If the conversion to a common "larger" type is possible, the
     
    12261228  functions must check the type of all their operands, and implement the
    12271229  necessary conversions (at least one of the operands is an instance of the
    1228   defined type).  This is the recommended way; with Python 3.0 coercion will
     1230  defined type).  This is the recommended way; with Python 3 coercion will
    12291231  disappear completely.
    12301232
     
    12421244
    12431245
    1244 .. ctype:: PyMappingMethods
     1246.. c:type:: PyMappingMethods
    12451247
    12461248   This structure holds pointers to the functions which an object uses to
    12471249   implement the mapping protocol.  It has three members:
    12481250
    1249 .. cmember:: lenfunc PyMappingMethods.mp_length
    1250 
    1251    This function is used by :cfunc:`PyMapping_Length` and
    1252    :cfunc:`PyObject_Size`, and has the same signature.  This slot may be set to
     1251.. c:member:: lenfunc PyMappingMethods.mp_length
     1252
     1253   This function is used by :c:func:`PyMapping_Length` and
     1254   :c:func:`PyObject_Size`, and has the same signature.  This slot may be set to
    12531255   *NULL* if the object has no defined length.
    12541256
    1255 .. cmember:: binaryfunc PyMappingMethods.mp_subscript
    1256 
    1257    This function is used by :cfunc:`PyObject_GetItem` and has the same
    1258    signature.  This slot must be filled for the :cfunc:`PyMapping_Check`
     1257.. c:member:: binaryfunc PyMappingMethods.mp_subscript
     1258
     1259   This function is used by :c:func:`PyObject_GetItem` and has the same
     1260   signature.  This slot must be filled for the :c:func:`PyMapping_Check`
    12591261   function to return ``1``, it can be *NULL* otherwise.
    12601262
    1261 .. cmember:: objobjargproc PyMappingMethods.mp_ass_subscript
    1262 
    1263    This function is used by :cfunc:`PyObject_SetItem` and has the same
     1263.. c:member:: objobjargproc PyMappingMethods.mp_ass_subscript
     1264
     1265   This function is used by :c:func:`PyObject_SetItem` and has the same
    12641266   signature.  If this slot is *NULL*, the object does not support item
    12651267   assignment.
     
    12741276
    12751277
    1276 .. ctype:: PySequenceMethods
     1278.. c:type:: PySequenceMethods
    12771279
    12781280   This structure holds pointers to the functions which an object uses to
    12791281   implement the sequence protocol.
    12801282
    1281 .. cmember:: lenfunc PySequenceMethods.sq_length
    1282 
    1283    This function is used by :cfunc:`PySequence_Size` and :cfunc:`PyObject_Size`,
     1283.. c:member:: lenfunc PySequenceMethods.sq_length
     1284
     1285   This function is used by :c:func:`PySequence_Size` and :c:func:`PyObject_Size`,
    12841286   and has the same signature.
    12851287
    1286 .. cmember:: binaryfunc PySequenceMethods.sq_concat
    1287 
    1288    This function is used by :cfunc:`PySequence_Concat` and has the same
     1288.. c:member:: binaryfunc PySequenceMethods.sq_concat
     1289
     1290   This function is used by :c:func:`PySequence_Concat` and has the same
    12891291   signature.  It is also used by the ``+`` operator, after trying the numeric
    1290    addition via the :attr:`tp_as_number.nb_add` slot.
    1291 
    1292 .. cmember:: ssizeargfunc PySequenceMethods.sq_repeat
    1293 
    1294    This function is used by :cfunc:`PySequence_Repeat` and has the same
     1292   addition via the :c:member:`~PyTypeObject.tp_as_number.nb_add` slot.
     1293
     1294.. c:member:: ssizeargfunc PySequenceMethods.sq_repeat
     1295
     1296   This function is used by :c:func:`PySequence_Repeat` and has the same
    12951297   signature.  It is also used by the ``*`` operator, after trying numeric
    1296    multiplication via the :attr:`tp_as_number.nb_mul` slot.
    1297 
    1298 .. cmember:: ssizeargfunc PySequenceMethods.sq_item
    1299 
    1300    This function is used by :cfunc:`PySequence_GetItem` and has the same
    1301    signature.  This slot must be filled for the :cfunc:`PySequence_Check`
     1298   multiplication via the :c:member:`~PyTypeObject.tp_as_number.nb_mul` slot.
     1299
     1300.. c:member:: ssizeargfunc PySequenceMethods.sq_item
     1301
     1302   This function is used by :c:func:`PySequence_GetItem` and has the same
     1303   signature.  This slot must be filled for the :c:func:`PySequence_Check`
    13021304   function to return ``1``, it can be *NULL* otherwise.
    13031305
     
    13071309   the index is passed as is to the function.
    13081310
    1309 .. cmember:: ssizeobjargproc PySequenceMethods.sq_ass_item
    1310 
    1311    This function is used by :cfunc:`PySequence_SetItem` and has the same
     1311.. c:member:: ssizeobjargproc PySequenceMethods.sq_ass_item
     1312
     1313   This function is used by :c:func:`PySequence_SetItem` and has the same
    13121314   signature.  This slot may be left to *NULL* if the object does not support
    13131315   item assignment.
    13141316
    1315 .. cmember:: objobjproc PySequenceMethods.sq_contains
    1316 
    1317    This function may be used by :cfunc:`PySequence_Contains` and has the same
     1317.. c:member:: objobjproc PySequenceMethods.sq_contains
     1318
     1319   This function may be used by :c:func:`PySequence_Contains` and has the same
    13181320   signature.  This slot may be left to *NULL*, in this case
    1319    :cfunc:`PySequence_Contains` simply traverses the sequence until it finds a
     1321   :c:func:`PySequence_Contains` simply traverses the sequence until it finds a
    13201322   match.
    13211323
    1322 .. cmember:: binaryfunc PySequenceMethods.sq_inplace_concat
    1323 
    1324    This function is used by :cfunc:`PySequence_InPlaceConcat` and has the same
     1324.. c:member:: binaryfunc PySequenceMethods.sq_inplace_concat
     1325
     1326   This function is used by :c:func:`PySequence_InPlaceConcat` and has the same
    13251327   signature.  It should modify its first operand, and return it.
    13261328
    1327 .. cmember:: ssizeargfunc PySequenceMethods.sq_inplace_repeat
    1328 
    1329    This function is used by :cfunc:`PySequence_InPlaceRepeat` and has the same
     1329.. c:member:: ssizeargfunc PySequenceMethods.sq_inplace_repeat
     1330
     1331   This function is used by :c:func:`PySequence_InPlaceRepeat` and has the same
    13301332   signature.  It should modify its first operand, and return it.
    13311333
     
    13471349to be non-contiguous in memory.
    13481350
    1349 If an object does not export the buffer interface, then its :attr:`tp_as_buffer`
    1350 member in the :ctype:`PyTypeObject` structure should be *NULL*.  Otherwise, the
    1351 :attr:`tp_as_buffer` will point to a :ctype:`PyBufferProcs` structure.
     1351If an object does not export the buffer interface, then its :c:member:`~PyTypeObject.tp_as_buffer`
     1352member in the :c:type:`PyTypeObject` structure should be *NULL*.  Otherwise, the
     1353:c:member:`~PyTypeObject.tp_as_buffer` will point to a :c:type:`PyBufferProcs` structure.
    13521354
    13531355.. note::
    13541356
    1355    It is very important that your :ctype:`PyTypeObject` structure uses
    1356    :const:`Py_TPFLAGS_DEFAULT` for the value of the :attr:`tp_flags` member rather
    1357    than ``0``.  This tells the Python runtime that your :ctype:`PyBufferProcs`
     1357   It is very important that your :c:type:`PyTypeObject` structure uses
     1358   :const:`Py_TPFLAGS_DEFAULT` for the value of the :c:member:`~PyTypeObject.tp_flags` member rather
     1359   than ``0``.  This tells the Python runtime that your :c:type:`PyBufferProcs`
    13581360   structure contains the :attr:`bf_getcharbuffer` slot. Older versions of Python
    13591361   did not have this member, so a new Python interpreter using an old extension
     
    13611363
    13621364
    1363 .. ctype:: PyBufferProcs
     1365.. c:type:: PyBufferProcs
    13641366
    13651367   Structure used to hold the function pointers which define an implementation of
    13661368   the buffer protocol.
    13671369
    1368    The first slot is :attr:`bf_getreadbuffer`, of type :ctype:`getreadbufferproc`.
     1370   The first slot is :attr:`bf_getreadbuffer`, of type :c:type:`getreadbufferproc`.
    13691371   If this slot is *NULL*, then the object does not support reading from the
    13701372   internal data.  This is non-sensical, so implementors should fill this in, but
     
    13721374
    13731375   The next slot is :attr:`bf_getwritebuffer` having type
    1374    :ctype:`getwritebufferproc`.  This slot may be *NULL* if the object does not
     1376   :c:type:`getwritebufferproc`.  This slot may be *NULL* if the object does not
    13751377   allow writing into its returned buffers.
    13761378
    1377    The third slot is :attr:`bf_getsegcount`, with type :ctype:`getsegcountproc`.
     1379   The third slot is :attr:`bf_getsegcount`, with type :c:type:`getsegcountproc`.
    13781380   This slot must not be *NULL* and is used to inform the caller how many segments
    1379    the object contains.  Simple objects such as :ctype:`PyString_Type` and
    1380    :ctype:`PyBuffer_Type` objects contain a single segment.
     1381   the object contains.  Simple objects such as :c:type:`PyString_Type` and
     1382   :c:type:`PyBuffer_Type` objects contain a single segment.
    13811383
    13821384   .. index:: single: PyType_HasFeature()
    13831385
    1384    The last slot is :attr:`bf_getcharbuffer`, of type :ctype:`getcharbufferproc`.
     1386   The last slot is :attr:`bf_getcharbuffer`, of type :c:type:`getcharbufferproc`.
    13851387   This slot will only be present if the :const:`Py_TPFLAGS_HAVE_GETCHARBUFFER`
    1386    flag is present in the :attr:`tp_flags` field of the object's
    1387    :ctype:`PyTypeObject`. Before using this slot, the caller should test whether it
    1388    is present by using the :cfunc:`PyType_HasFeature` function.  If the flag is
     1388   flag is present in the :c:member:`~PyTypeObject.tp_flags` field of the object's
     1389   :c:type:`PyTypeObject`. Before using this slot, the caller should test whether it
     1390   is present by using the :c:func:`PyType_HasFeature` function.  If the flag is
    13891391   present, :attr:`bf_getcharbuffer` may be *NULL*, indicating that the object's
    13901392   contents cannot be used as *8-bit characters*. The slot function may also raise
     
    14101412
    14111413
    1412 .. ctype:: Py_ssize_t (*readbufferproc) (PyObject *self, Py_ssize_t segment, void **ptrptr)
     1414.. c:type:: Py_ssize_t (*readbufferproc) (PyObject *self, Py_ssize_t segment, void **ptrptr)
    14131415
    14141416   Return a pointer to a readable segment of the buffer in ``*ptrptr``.  This
     
    14201422
    14211423
    1422 .. ctype:: Py_ssize_t (*writebufferproc) (PyObject *self, Py_ssize_t segment, void **ptrptr)
     1424.. c:type:: Py_ssize_t (*writebufferproc) (PyObject *self, Py_ssize_t segment, void **ptrptr)
    14231425
    14241426   Return a pointer to a writable memory buffer in ``*ptrptr``, and the length of
     
    14341436
    14351437
    1436 .. ctype:: Py_ssize_t (*segcountproc) (PyObject *self, Py_ssize_t *lenp)
     1438.. c:type:: Py_ssize_t (*segcountproc) (PyObject *self, Py_ssize_t *lenp)
    14371439
    14381440   Return the number of memory segments which comprise the buffer.  If *lenp* is
     
    14411443
    14421444
    1443 .. ctype:: Py_ssize_t (*charbufferproc) (PyObject *self, Py_ssize_t segment, const char **ptrptr)
     1445.. c:type:: Py_ssize_t (*charbufferproc) (PyObject *self, Py_ssize_t segment, const char **ptrptr)
    14441446
    14451447   Return the size of the segment *segment* that *ptrptr*  is set to.  ``*ptrptr``
  • python/vendor/current/Doc/c-api/unicode.rst

    r2 r388  
    1212
    1313
     14Unicode Type
     15""""""""""""
     16
    1417These are the basic Unicode object types used for the Unicode implementation in
    1518Python:
    1619
    17 .. % --- Unicode Type -------------------------------------------------------
    18 
    19 
    20 .. ctype:: Py_UNICODE
     20
     21.. c:type:: Py_UNICODE
    2122
    2223   This type represents the storage type which is used by Python internally as
    2324   basis for holding Unicode ordinals.  Python's default builds use a 16-bit type
    24    for :ctype:`Py_UNICODE` and store Unicode values internally as UCS2. It is also
     25   for :c:type:`Py_UNICODE` and store Unicode values internally as UCS2. It is also
    2526   possible to build a UCS4 version of Python (most recent Linux distributions come
    2627   with UCS4 builds of Python). These builds then use a 32-bit type for
    27    :ctype:`Py_UNICODE` and store Unicode data internally as UCS4. On platforms
    28    where :ctype:`wchar_t` is available and compatible with the chosen Python
    29    Unicode build variant, :ctype:`Py_UNICODE` is a typedef alias for
    30    :ctype:`wchar_t` to enhance native platform compatibility. On all other
    31    platforms, :ctype:`Py_UNICODE` is a typedef alias for either :ctype:`unsigned
    32    short` (UCS2) or :ctype:`unsigned long` (UCS4).
     28   :c:type:`Py_UNICODE` and store Unicode data internally as UCS4. On platforms
     29   where :c:type:`wchar_t` is available and compatible with the chosen Python
     30   Unicode build variant, :c:type:`Py_UNICODE` is a typedef alias for
     31   :c:type:`wchar_t` to enhance native platform compatibility. On all other
     32   platforms, :c:type:`Py_UNICODE` is a typedef alias for either :c:type:`unsigned
     33   short` (UCS2) or :c:type:`unsigned long` (UCS4).
    3334
    3435Note that UCS2 and UCS4 Python builds are not binary compatible. Please keep
     
    3637
    3738
    38 .. ctype:: PyUnicodeObject
    39 
    40    This subtype of :ctype:`PyObject` represents a Python Unicode object.
    41 
    42 
    43 .. cvar:: PyTypeObject PyUnicode_Type
    44 
    45    This instance of :ctype:`PyTypeObject` represents the Python Unicode type.  It
     39.. c:type:: PyUnicodeObject
     40
     41   This subtype of :c:type:`PyObject` represents a Python Unicode object.
     42
     43
     44.. c:var:: PyTypeObject PyUnicode_Type
     45
     46   This instance of :c:type:`PyTypeObject` represents the Python Unicode type.  It
    4647   is exposed to Python code as ``unicode`` and ``types.UnicodeType``.
    4748
     
    5051
    5152
    52 .. cfunction:: int PyUnicode_Check(PyObject *o)
     53.. c:function:: int PyUnicode_Check(PyObject *o)
    5354
    5455   Return true if the object *o* is a Unicode object or an instance of a Unicode
     
    5960
    6061
    61 .. cfunction:: int PyUnicode_CheckExact(PyObject *o)
     62.. c:function:: int PyUnicode_CheckExact(PyObject *o)
    6263
    6364   Return true if the object *o* is a Unicode object, but not an instance of a
     
    6768
    6869
    69 .. cfunction:: Py_ssize_t PyUnicode_GET_SIZE(PyObject *o)
    70 
    71    Return the size of the object.  *o* has to be a :ctype:`PyUnicodeObject` (not
     70.. c:function:: Py_ssize_t PyUnicode_GET_SIZE(PyObject *o)
     71
     72   Return the size of the object.  *o* has to be a :c:type:`PyUnicodeObject` (not
    7273   checked).
    7374
    7475   .. versionchanged:: 2.5
    75       This function returned an :ctype:`int` type. This might require changes
     76      This function returned an :c:type:`int` type. This might require changes
    7677      in your code for properly supporting 64-bit systems.
    7778
    7879
    79 .. cfunction:: Py_ssize_t PyUnicode_GET_DATA_SIZE(PyObject *o)
     80.. c:function:: Py_ssize_t PyUnicode_GET_DATA_SIZE(PyObject *o)
    8081
    8182   Return the size of the object's internal buffer in bytes.  *o* has to be a
    82    :ctype:`PyUnicodeObject` (not checked).
    83 
    84    .. versionchanged:: 2.5
    85       This function returned an :ctype:`int` type. This might require changes
     83   :c:type:`PyUnicodeObject` (not checked).
     84
     85   .. versionchanged:: 2.5
     86      This function returned an :c:type:`int` type. This might require changes
    8687      in your code for properly supporting 64-bit systems.
    8788
    8889
    89 .. cfunction:: Py_UNICODE* PyUnicode_AS_UNICODE(PyObject *o)
    90 
    91    Return a pointer to the internal :ctype:`Py_UNICODE` buffer of the object.  *o*
    92    has to be a :ctype:`PyUnicodeObject` (not checked).
    93 
    94 
    95 .. cfunction:: const char* PyUnicode_AS_DATA(PyObject *o)
     90.. c:function:: Py_UNICODE* PyUnicode_AS_UNICODE(PyObject *o)
     91
     92   Return a pointer to the internal :c:type:`Py_UNICODE` buffer of the object.  *o*
     93   has to be a :c:type:`PyUnicodeObject` (not checked).
     94
     95
     96.. c:function:: const char* PyUnicode_AS_DATA(PyObject *o)
    9697
    9798   Return a pointer to the internal buffer of the object. *o* has to be a
    98    :ctype:`PyUnicodeObject` (not checked).
    99 
    100 
    101 .. cfunction:: int PyUnicode_ClearFreeList()
     99   :c:type:`PyUnicodeObject` (not checked).
     100
     101
     102.. c:function:: int PyUnicode_ClearFreeList()
    102103
    103104   Clear the free list. Return the total number of freed items.
     
    105106   .. versionadded:: 2.6
    106107
     108
     109Unicode Character Properties
     110""""""""""""""""""""""""""""
    107111
    108112Unicode provides many different character properties. The most often needed ones
     
    110114the Python configuration.
    111115
    112 .. % --- Unicode character properties ---------------------------------------
    113 
    114 
    115 .. cfunction:: int Py_UNICODE_ISSPACE(Py_UNICODE ch)
     116
     117.. c:function:: int Py_UNICODE_ISSPACE(Py_UNICODE ch)
    116118
    117119   Return 1 or 0 depending on whether *ch* is a whitespace character.
    118120
    119121
    120 .. cfunction:: int Py_UNICODE_ISLOWER(Py_UNICODE ch)
     122.. c:function:: int Py_UNICODE_ISLOWER(Py_UNICODE ch)
    121123
    122124   Return 1 or 0 depending on whether *ch* is a lowercase character.
    123125
    124126
    125 .. cfunction:: int Py_UNICODE_ISUPPER(Py_UNICODE ch)
     127.. c:function:: int Py_UNICODE_ISUPPER(Py_UNICODE ch)
    126128
    127129   Return 1 or 0 depending on whether *ch* is an uppercase character.
    128130
    129131
    130 .. cfunction:: int Py_UNICODE_ISTITLE(Py_UNICODE ch)
     132.. c:function:: int Py_UNICODE_ISTITLE(Py_UNICODE ch)
    131133
    132134   Return 1 or 0 depending on whether *ch* is a titlecase character.
    133135
    134136
    135 .. cfunction:: int Py_UNICODE_ISLINEBREAK(Py_UNICODE ch)
     137.. c:function:: int Py_UNICODE_ISLINEBREAK(Py_UNICODE ch)
    136138
    137139   Return 1 or 0 depending on whether *ch* is a linebreak character.
    138140
    139141
    140 .. cfunction:: int Py_UNICODE_ISDECIMAL(Py_UNICODE ch)
     142.. c:function:: int Py_UNICODE_ISDECIMAL(Py_UNICODE ch)
    141143
    142144   Return 1 or 0 depending on whether *ch* is a decimal character.
    143145
    144146
    145 .. cfunction:: int Py_UNICODE_ISDIGIT(Py_UNICODE ch)
     147.. c:function:: int Py_UNICODE_ISDIGIT(Py_UNICODE ch)
    146148
    147149   Return 1 or 0 depending on whether *ch* is a digit character.
    148150
    149151
    150 .. cfunction:: int Py_UNICODE_ISNUMERIC(Py_UNICODE ch)
     152.. c:function:: int Py_UNICODE_ISNUMERIC(Py_UNICODE ch)
    151153
    152154   Return 1 or 0 depending on whether *ch* is a numeric character.
    153155
    154156
    155 .. cfunction:: int Py_UNICODE_ISALPHA(Py_UNICODE ch)
     157.. c:function:: int Py_UNICODE_ISALPHA(Py_UNICODE ch)
    156158
    157159   Return 1 or 0 depending on whether *ch* is an alphabetic character.
    158160
    159161
    160 .. cfunction:: int Py_UNICODE_ISALNUM(Py_UNICODE ch)
     162.. c:function:: int Py_UNICODE_ISALNUM(Py_UNICODE ch)
    161163
    162164   Return 1 or 0 depending on whether *ch* is an alphanumeric character.
     
    165167
    166168
    167 .. cfunction:: Py_UNICODE Py_UNICODE_TOLOWER(Py_UNICODE ch)
     169.. c:function:: Py_UNICODE Py_UNICODE_TOLOWER(Py_UNICODE ch)
    168170
    169171   Return the character *ch* converted to lower case.
    170172
    171173
    172 .. cfunction:: Py_UNICODE Py_UNICODE_TOUPPER(Py_UNICODE ch)
     174.. c:function:: Py_UNICODE Py_UNICODE_TOUPPER(Py_UNICODE ch)
    173175
    174176   Return the character *ch* converted to upper case.
    175177
    176178
    177 .. cfunction:: Py_UNICODE Py_UNICODE_TOTITLE(Py_UNICODE ch)
     179.. c:function:: Py_UNICODE Py_UNICODE_TOTITLE(Py_UNICODE ch)
    178180
    179181   Return the character *ch* converted to title case.
    180182
    181183
    182 .. cfunction:: int Py_UNICODE_TODECIMAL(Py_UNICODE ch)
     184.. c:function:: int Py_UNICODE_TODECIMAL(Py_UNICODE ch)
    183185
    184186   Return the character *ch* converted to a decimal positive integer.  Return
     
    186188
    187189
    188 .. cfunction:: int Py_UNICODE_TODIGIT(Py_UNICODE ch)
     190.. c:function:: int Py_UNICODE_TODIGIT(Py_UNICODE ch)
    189191
    190192   Return the character *ch* converted to a single digit integer. Return ``-1`` if
     
    192194
    193195
    194 .. cfunction:: double Py_UNICODE_TONUMERIC(Py_UNICODE ch)
     196.. c:function:: double Py_UNICODE_TONUMERIC(Py_UNICODE ch)
    195197
    196198   Return the character *ch* converted to a double. Return ``-1.0`` if this is not
    197199   possible.  This macro does not raise exceptions.
    198200
     201
     202Plain Py_UNICODE
     203""""""""""""""""
     204
    199205To create Unicode objects and access their basic sequence properties, use these
    200206APIs:
    201207
    202 .. % --- Plain Py_UNICODE ---------------------------------------------------
    203 
    204 
    205 .. cfunction:: PyObject* PyUnicode_FromUnicode(const Py_UNICODE *u, Py_ssize_t size)
    206 
    207    Create a Unicode Object from the Py_UNICODE buffer *u* of the given size. *u*
     208
     209.. c:function:: PyObject* PyUnicode_FromUnicode(const Py_UNICODE *u, Py_ssize_t size)
     210
     211   Create a Unicode object from the Py_UNICODE buffer *u* of the given size. *u*
    208212   may be *NULL* which causes the contents to be undefined. It is the user's
    209213   responsibility to fill in the needed data.  The buffer is copied into the new
     
    213217
    214218   .. versionchanged:: 2.5
    215       This function used an :ctype:`int` type for *size*. This might require
    216       changes in your code for properly supporting 64-bit systems.
    217 
    218 
    219 .. cfunction:: Py_UNICODE* PyUnicode_AsUnicode(PyObject *unicode)
    220 
    221    Return a read-only pointer to the Unicode object's internal :ctype:`Py_UNICODE`
    222    buffer, *NULL* if *unicode* is not a Unicode object.
    223 
    224 
    225 .. cfunction:: Py_ssize_t PyUnicode_GetSize(PyObject *unicode)
     219      This function used an :c:type:`int` type for *size*. This might require
     220      changes in your code for properly supporting 64-bit systems.
     221
     222
     223.. c:function:: PyObject* PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size)
     224
     225   Create a Unicode object from the char buffer *u*.  The bytes will be interpreted
     226   as being UTF-8 encoded.  *u* may also be *NULL* which
     227   causes the contents to be undefined. It is the user's responsibility to fill in
     228   the needed data.  The buffer is copied into the new object. If the buffer is not
     229   *NULL*, the return value might be a shared object. Therefore, modification of
     230   the resulting Unicode object is only allowed when *u* is *NULL*.
     231
     232   .. versionadded:: 2.6
     233
     234
     235.. c:function:: PyObject *PyUnicode_FromString(const char *u)
     236
     237   Create a Unicode object from an UTF-8 encoded null-terminated char buffer
     238   *u*.
     239
     240   .. versionadded:: 2.6
     241
     242
     243.. c:function:: PyObject* PyUnicode_FromFormat(const char *format, ...)
     244
     245   Take a C :c:func:`printf`\ -style *format* string and a variable number of
     246   arguments, calculate the size of the resulting Python unicode string and return
     247   a string with the values formatted into it.  The variable arguments must be C
     248   types and must correspond exactly to the format characters in the *format*
     249   string.  The following format characters are allowed:
     250
     251   .. % The descriptions for %zd and %zu are wrong, but the truth is complicated
     252   .. % because not all compilers support the %z width modifier -- we fake it
     253   .. % when necessary via interpolating PY_FORMAT_SIZE_T.
     254
     255   .. tabularcolumns:: |l|l|L|
     256
     257   +-------------------+---------------------+--------------------------------+
     258   | Format Characters | Type                | Comment                        |
     259   +===================+=====================+================================+
     260   | :attr:`%%`        | *n/a*               | The literal % character.       |
     261   +-------------------+---------------------+--------------------------------+
     262   | :attr:`%c`        | int                 | A single character,            |
     263   |                   |                     | represented as an C int.       |
     264   +-------------------+---------------------+--------------------------------+
     265   | :attr:`%d`        | int                 | Exactly equivalent to          |
     266   |                   |                     | ``printf("%d")``.              |
     267   +-------------------+---------------------+--------------------------------+
     268   | :attr:`%u`        | unsigned int        | Exactly equivalent to          |
     269   |                   |                     | ``printf("%u")``.              |
     270   +-------------------+---------------------+--------------------------------+
     271   | :attr:`%ld`       | long                | Exactly equivalent to          |
     272   |                   |                     | ``printf("%ld")``.             |
     273   +-------------------+---------------------+--------------------------------+
     274   | :attr:`%lu`       | unsigned long       | Exactly equivalent to          |
     275   |                   |                     | ``printf("%lu")``.             |
     276   +-------------------+---------------------+--------------------------------+
     277   | :attr:`%zd`       | Py_ssize_t          | Exactly equivalent to          |
     278   |                   |                     | ``printf("%zd")``.             |
     279   +-------------------+---------------------+--------------------------------+
     280   | :attr:`%zu`       | size_t              | Exactly equivalent to          |
     281   |                   |                     | ``printf("%zu")``.             |
     282   +-------------------+---------------------+--------------------------------+
     283   | :attr:`%i`        | int                 | Exactly equivalent to          |
     284   |                   |                     | ``printf("%i")``.              |
     285   +-------------------+---------------------+--------------------------------+
     286   | :attr:`%x`        | int                 | Exactly equivalent to          |
     287   |                   |                     | ``printf("%x")``.              |
     288   +-------------------+---------------------+--------------------------------+
     289   | :attr:`%s`        | char\*              | A null-terminated C character  |
     290   |                   |                     | array.                         |
     291   +-------------------+---------------------+--------------------------------+
     292   | :attr:`%p`        | void\*              | The hex representation of a C  |
     293   |                   |                     | pointer. Mostly equivalent to  |
     294   |                   |                     | ``printf("%p")`` except that   |
     295   |                   |                     | it is guaranteed to start with |
     296   |                   |                     | the literal ``0x`` regardless  |
     297   |                   |                     | of what the platform's         |
     298   |                   |                     | ``printf`` yields.             |
     299   +-------------------+---------------------+--------------------------------+
     300   | :attr:`%U`        | PyObject\*          | A unicode object.              |
     301   +-------------------+---------------------+--------------------------------+
     302   | :attr:`%V`        | PyObject\*, char \* | A unicode object (which may be |
     303   |                   |                     | *NULL*) and a null-terminated  |
     304   |                   |                     | C character array as a second  |
     305   |                   |                     | parameter (which will be used, |
     306   |                   |                     | if the first parameter is      |
     307   |                   |                     | *NULL*).                       |
     308   +-------------------+---------------------+--------------------------------+
     309   | :attr:`%S`        | PyObject\*          | The result of calling          |
     310   |                   |                     | :func:`PyObject_Unicode`.      |
     311   +-------------------+---------------------+--------------------------------+
     312   | :attr:`%R`        | PyObject\*          | The result of calling          |
     313   |                   |                     | :func:`PyObject_Repr`.         |
     314   +-------------------+---------------------+--------------------------------+
     315
     316   An unrecognized format character causes all the rest of the format string to be
     317   copied as-is to the result string, and any extra arguments discarded.
     318
     319   .. versionadded:: 2.6
     320
     321
     322.. c:function:: PyObject* PyUnicode_FromFormatV(const char *format, va_list vargs)
     323
     324   Identical to :func:`PyUnicode_FromFormat` except that it takes exactly two
     325   arguments.
     326
     327   .. versionadded:: 2.6
     328
     329
     330.. c:function:: Py_UNICODE* PyUnicode_AsUnicode(PyObject *unicode)
     331
     332   Return a read-only pointer to the Unicode object's internal
     333   :c:type:`Py_UNICODE` buffer, *NULL* if *unicode* is not a Unicode object.
     334   Note that the resulting :c:type:`Py_UNICODE*` string may contain embedded
     335   null characters, which would cause the string to be truncated when used in
     336   most C functions.
     337
     338
     339.. c:function:: Py_ssize_t PyUnicode_GetSize(PyObject *unicode)
    226340
    227341   Return the length of the Unicode object.
    228342
    229343   .. versionchanged:: 2.5
    230       This function returned an :ctype:`int` type. This might require changes
     344      This function returned an :c:type:`int` type. This might require changes
    231345      in your code for properly supporting 64-bit systems.
    232346
    233347
    234 .. cfunction:: PyObject* PyUnicode_FromEncodedObject(PyObject *obj, const char *encoding, const char *errors)
     348.. c:function:: PyObject* PyUnicode_FromEncodedObject(PyObject *obj, const char *encoding, const char *errors)
    235349
    236350   Coerce an encoded object *obj* to an Unicode object and return a reference with
     
    249363
    250364
    251 .. cfunction:: PyObject* PyUnicode_FromObject(PyObject *obj)
     365.. c:function:: PyObject* PyUnicode_FromObject(PyObject *obj)
    252366
    253367   Shortcut for ``PyUnicode_FromEncodedObject(obj, NULL, "strict")`` which is used
    254368   throughout the interpreter whenever coercion to Unicode is needed.
    255369
    256 If the platform supports :ctype:`wchar_t` and provides a header file wchar.h,
     370If the platform supports :c:type:`wchar_t` and provides a header file wchar.h,
    257371Python can interface directly to this type using the following functions.
    258 Support is optimized if Python's own :ctype:`Py_UNICODE` type is identical to
    259 the system's :ctype:`wchar_t`.
    260 
    261 .. % --- wchar_t support for platforms which support it ---------------------
    262 
    263 
    264 .. cfunction:: PyObject* PyUnicode_FromWideChar(const wchar_t *w, Py_ssize_t size)
    265 
    266    Create a Unicode object from the :ctype:`wchar_t` buffer *w* of the given size.
     372Support is optimized if Python's own :c:type:`Py_UNICODE` type is identical to
     373the system's :c:type:`wchar_t`.
     374
     375
     376wchar_t Support
     377"""""""""""""""
     378
     379:c:type:`wchar_t` support for platforms which support it:
     380
     381.. c:function:: PyObject* PyUnicode_FromWideChar(const wchar_t *w, Py_ssize_t size)
     382
     383   Create a Unicode object from the :c:type:`wchar_t` buffer *w* of the given *size*.
    267384   Return *NULL* on failure.
    268385
    269386   .. versionchanged:: 2.5
    270       This function used an :ctype:`int` type for *size*. This might require
    271       changes in your code for properly supporting 64-bit systems.
    272 
    273 
    274 .. cfunction:: Py_ssize_t PyUnicode_AsWideChar(PyUnicodeObject *unicode, wchar_t *w, Py_ssize_t size)
    275 
    276    Copy the Unicode object contents into the :ctype:`wchar_t` buffer *w*.  At most
    277    *size* :ctype:`wchar_t` characters are copied (excluding a possibly trailing
    278    0-termination character).  Return the number of :ctype:`wchar_t` characters
    279    copied or -1 in case of an error.  Note that the resulting :ctype:`wchar_t`
     387      This function used an :c:type:`int` type for *size*. This might require
     388      changes in your code for properly supporting 64-bit systems.
     389
     390
     391.. c:function:: Py_ssize_t PyUnicode_AsWideChar(PyUnicodeObject *unicode, wchar_t *w, Py_ssize_t size)
     392
     393   Copy the Unicode object contents into the :c:type:`wchar_t` buffer *w*.  At most
     394   *size* :c:type:`wchar_t` characters are copied (excluding a possibly trailing
     395   0-termination character).  Return the number of :c:type:`wchar_t` characters
     396   copied or -1 in case of an error.  Note that the resulting :c:type:`wchar_t`
    280397   string may or may not be 0-terminated.  It is the responsibility of the caller
    281    to make sure that the :ctype:`wchar_t` string is 0-terminated in case this is
    282    required by the application.
    283 
    284    .. versionchanged:: 2.5
    285       This function returned an :ctype:`int` type and used an :ctype:`int`
     398   to make sure that the :c:type:`wchar_t` string is 0-terminated in case this is
     399   required by the application. Also, note that the :c:type:`wchar_t*` string
     400   might contain null characters, which would cause the string to be truncated
     401   when used with most C functions.
     402
     403   .. versionchanged:: 2.5
     404      This function returned an :c:type:`int` type and used an :c:type:`int`
    286405      type for *size*. This might require changes in your code for properly
    287406      supporting 64-bit systems.
     
    296415these codecs are directly usable via the following functions.
    297416
    298 Many of the following APIs take two arguments encoding and errors. These
    299 parameters encoding and errors have the same semantics as the ones of the
    300 built-in :func:`unicode` Unicode object constructor.
     417Many of the following APIs take two arguments encoding and errors, and they
     418have the same semantics as the ones of the built-in :func:`unicode` Unicode
     419object constructor.
    301420
    302421Setting encoding to *NULL* causes the default encoding to be used which is
    303 ASCII.  The file system calls should use :cdata:`Py_FileSystemDefaultEncoding`
    304 as the encoding for file names. This variable should be treated as read-only: On
     422ASCII.  The file system calls should use :c:data:`Py_FileSystemDefaultEncoding`
     423as the encoding for file names. This variable should be treated as read-only: on
    305424some systems, it will be a pointer to a static string, on others, it will change
    306425at run-time (such as when the application invokes setlocale).
     
    313432generic ones are documented for simplicity.
    314433
     434
     435Generic Codecs
     436""""""""""""""
     437
    315438These are the generic codec APIs:
    316439
    317 .. % --- Generic Codecs -----------------------------------------------------
    318 
    319 
    320 .. cfunction:: PyObject* PyUnicode_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)
     440
     441.. c:function:: PyObject* PyUnicode_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)
    321442
    322443   Create a Unicode object by decoding *size* bytes of the encoded string *s*.
     
    327448
    328449   .. versionchanged:: 2.5
    329       This function used an :ctype:`int` type for *size*. This might require
    330       changes in your code for properly supporting 64-bit systems.
    331 
    332 
    333 .. cfunction:: PyObject* PyUnicode_Encode(const Py_UNICODE *s, Py_ssize_t size, const char *encoding, const char *errors)
    334 
    335    Encode the :ctype:`Py_UNICODE` buffer of the given size and return a Python
     450      This function used an :c:type:`int` type for *size*. This might require
     451      changes in your code for properly supporting 64-bit systems.
     452
     453
     454.. c:function:: PyObject* PyUnicode_Encode(const Py_UNICODE *s, Py_ssize_t size, const char *encoding, const char *errors)
     455
     456   Encode the :c:type:`Py_UNICODE` buffer *s* of the given *size* and return a Python
    336457   string object.  *encoding* and *errors* have the same meaning as the parameters
    337    of the same name in the Unicode :meth:`encode` method.  The codec to be used is
    338    looked up using the Python codec registry.  Return *NULL* if an exception was
    339    raised by the codec.
    340 
    341    .. versionchanged:: 2.5
    342       This function used an :ctype:`int` type for *size*. This might require
    343       changes in your code for properly supporting 64-bit systems.
    344 
    345 
    346 .. cfunction:: PyObject* PyUnicode_AsEncodedString(PyObject *unicode, const char *encoding, const char *errors)
     458   of the same name in the Unicode :meth:`~unicode.encode` method.  The codec
     459   to be used is looked up using the Python codec registry.  Return *NULL* if
     460   an exception was raised by the codec.
     461
     462   .. versionchanged:: 2.5
     463      This function used an :c:type:`int` type for *size*. This might require
     464      changes in your code for properly supporting 64-bit systems.
     465
     466
     467.. c:function:: PyObject* PyUnicode_AsEncodedString(PyObject *unicode, const char *encoding, const char *errors)
    347468
    348469   Encode a Unicode object and return the result as Python string object.
     
    352473   codec.
    353474
     475
     476UTF-8 Codecs
     477""""""""""""
     478
    354479These are the UTF-8 codec APIs:
    355480
    356 .. % --- UTF-8 Codecs -------------------------------------------------------
    357 
    358 
    359 .. cfunction:: PyObject* PyUnicode_DecodeUTF8(const char *s, Py_ssize_t size, const char *errors)
     481
     482.. c:function:: PyObject* PyUnicode_DecodeUTF8(const char *s, Py_ssize_t size, const char *errors)
    360483
    361484   Create a Unicode object by decoding *size* bytes of the UTF-8 encoded string
     
    363486
    364487   .. versionchanged:: 2.5
    365       This function used an :ctype:`int` type for *size*. This might require
    366       changes in your code for properly supporting 64-bit systems.
    367 
    368 
    369 .. cfunction:: PyObject* PyUnicode_DecodeUTF8Stateful(const char *s, Py_ssize_t size, const char *errors, Py_ssize_t *consumed)
    370 
    371    If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeUTF8`. If
     488      This function used an :c:type:`int` type for *size*. This might require
     489      changes in your code for properly supporting 64-bit systems.
     490
     491
     492.. c:function:: PyObject* PyUnicode_DecodeUTF8Stateful(const char *s, Py_ssize_t size, const char *errors, Py_ssize_t *consumed)
     493
     494   If *consumed* is *NULL*, behave like :c:func:`PyUnicode_DecodeUTF8`. If
    372495   *consumed* is not *NULL*, trailing incomplete UTF-8 byte sequences will not be
    373496   treated as an error. Those bytes will not be decoded and the number of bytes
     
    377500
    378501   .. versionchanged:: 2.5
    379       This function used an :ctype:`int` type for *size*. This might require
    380       changes in your code for properly supporting 64-bit systems.
    381 
    382 
    383 .. cfunction:: PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
    384 
    385    Encode the :ctype:`Py_UNICODE` buffer of the given size using UTF-8 and return a
     502      This function used an :c:type:`int` type for *size*. This might require
     503      changes in your code for properly supporting 64-bit systems.
     504
     505
     506.. c:function:: PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
     507
     508   Encode the :c:type:`Py_UNICODE` buffer *s* of the given *size* using UTF-8 and return a
    386509   Python string object.  Return *NULL* if an exception was raised by the codec.
    387510
    388511   .. versionchanged:: 2.5
    389       This function used an :ctype:`int` type for *size*. This might require
    390       changes in your code for properly supporting 64-bit systems.
    391 
    392 
    393 .. cfunction:: PyObject* PyUnicode_AsUTF8String(PyObject *unicode)
     512      This function used an :c:type:`int` type for *size*. This might require
     513      changes in your code for properly supporting 64-bit systems.
     514
     515
     516.. c:function:: PyObject* PyUnicode_AsUTF8String(PyObject *unicode)
    394517
    395518   Encode a Unicode object using UTF-8 and return the result as Python string
     
    397520   by the codec.
    398521
     522
     523UTF-32 Codecs
     524"""""""""""""
     525
    399526These are the UTF-32 codec APIs:
    400527
    401 .. % --- UTF-32 Codecs ------------------------------------------------------ */
    402 
    403 
    404 .. cfunction:: PyObject* PyUnicode_DecodeUTF32(const char *s, Py_ssize_t size, const char *errors, int *byteorder)
    405 
    406    Decode *length* bytes from a UTF-32 encoded buffer string and return the
     528
     529.. c:function:: PyObject* PyUnicode_DecodeUTF32(const char *s, Py_ssize_t size, const char *errors, int *byteorder)
     530
     531   Decode *size* bytes from a UTF-32 encoded buffer string and return the
    407532   corresponding Unicode object.  *errors* (if non-*NULL*) defines the error
    408533   handling. It defaults to "strict".
     
    432557
    433558
    434 .. cfunction:: PyObject* PyUnicode_DecodeUTF32Stateful(const char *s, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed)
    435 
    436    If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeUTF32`. If
    437    *consumed* is not *NULL*, :cfunc:`PyUnicode_DecodeUTF32Stateful` will not treat
     559.. c:function:: PyObject* PyUnicode_DecodeUTF32Stateful(const char *s, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed)
     560
     561   If *consumed* is *NULL*, behave like :c:func:`PyUnicode_DecodeUTF32`. If
     562   *consumed* is not *NULL*, :c:func:`PyUnicode_DecodeUTF32Stateful` will not treat
    438563   trailing incomplete UTF-32 byte sequences (such as a number of bytes not divisible
    439564   by four) as an error. Those bytes will not be decoded and the number of bytes
     
    443568
    444569
    445 .. cfunction:: PyObject* PyUnicode_EncodeUTF32(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder)
     570.. c:function:: PyObject* PyUnicode_EncodeUTF32(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder)
    446571
    447572   Return a Python bytes object holding the UTF-32 encoded value of the Unicode
     
    463588
    464589
    465 .. cfunction:: PyObject* PyUnicode_AsUTF32String(PyObject *unicode)
     590.. c:function:: PyObject* PyUnicode_AsUTF32String(PyObject *unicode)
    466591
    467592   Return a Python string using the UTF-32 encoding in native byte order. The
     
    472597
    473598
     599UTF-16 Codecs
     600"""""""""""""
     601
    474602These are the UTF-16 codec APIs:
    475603
    476 .. % --- UTF-16 Codecs ------------------------------------------------------ */
    477 
    478 
    479 .. cfunction:: PyObject* PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors, int *byteorder)
    480 
    481    Decode *length* bytes from a UTF-16 encoded buffer string and return the
     604
     605.. c:function:: PyObject* PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors, int *byteorder)
     606
     607   Decode *size* bytes from a UTF-16 encoded buffer string and return the
    482608   corresponding Unicode object.  *errors* (if non-*NULL*) defines the error
    483609   handling. It defaults to "strict".
     
    504630
    505631   .. versionchanged:: 2.5
    506       This function used an :ctype:`int` type for *size*. This might require
    507       changes in your code for properly supporting 64-bit systems.
    508 
    509 
    510 .. cfunction:: PyObject* PyUnicode_DecodeUTF16Stateful(const char *s, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed)
    511 
    512    If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeUTF16`. If
    513    *consumed* is not *NULL*, :cfunc:`PyUnicode_DecodeUTF16Stateful` will not treat
     632      This function used an :c:type:`int` type for *size*. This might require
     633      changes in your code for properly supporting 64-bit systems.
     634
     635
     636.. c:function:: PyObject* PyUnicode_DecodeUTF16Stateful(const char *s, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed)
     637
     638   If *consumed* is *NULL*, behave like :c:func:`PyUnicode_DecodeUTF16`. If
     639   *consumed* is not *NULL*, :c:func:`PyUnicode_DecodeUTF16Stateful` will not treat
    514640   trailing incomplete UTF-16 byte sequences (such as an odd number of bytes or a
    515641   split surrogate pair) as an error. Those bytes will not be decoded and the
     
    519645
    520646   .. versionchanged:: 2.5
    521       This function used an :ctype:`int` type for *size* and an :ctype:`int *`
     647      This function used an :c:type:`int` type for *size* and an :c:type:`int *`
    522648      type for *consumed*. This might require changes in your code for
    523649      properly supporting 64-bit systems.
    524650
    525651
    526 .. cfunction:: PyObject* PyUnicode_EncodeUTF16(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder)
     652.. c:function:: PyObject* PyUnicode_EncodeUTF16(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder)
    527653
    528654   Return a Python string object holding the UTF-16 encoded value of the Unicode
     
    536662   mark (U+FEFF). In the other two modes, no BOM mark is prepended.
    537663
    538    If *Py_UNICODE_WIDE* is defined, a single :ctype:`Py_UNICODE` value may get
    539    represented as a surrogate pair. If it is not defined, each :ctype:`Py_UNICODE`
     664   If *Py_UNICODE_WIDE* is defined, a single :c:type:`Py_UNICODE` value may get
     665   represented as a surrogate pair. If it is not defined, each :c:type:`Py_UNICODE`
    540666   values is interpreted as an UCS-2 character.
    541667
     
    543669
    544670   .. versionchanged:: 2.5
    545       This function used an :ctype:`int` type for *size*. This might require
    546       changes in your code for properly supporting 64-bit systems.
    547 
    548 
    549 .. cfunction:: PyObject* PyUnicode_AsUTF16String(PyObject *unicode)
     671      This function used an :c:type:`int` type for *size*. This might require
     672      changes in your code for properly supporting 64-bit systems.
     673
     674
     675.. c:function:: PyObject* PyUnicode_AsUTF16String(PyObject *unicode)
    550676
    551677   Return a Python string using the UTF-16 encoding in native byte order. The
     
    553679   *NULL* if an exception was raised by the codec.
    554680
     681
     682UTF-7 Codecs
     683""""""""""""
     684
     685These are the UTF-7 codec APIs:
     686
     687
     688.. c:function:: PyObject* PyUnicode_DecodeUTF7(const char *s, Py_ssize_t size, const char *errors)
     689
     690   Create a Unicode object by decoding *size* bytes of the UTF-7 encoded string
     691   *s*.  Return *NULL* if an exception was raised by the codec.
     692
     693
     694.. c:function:: PyObject* PyUnicode_DecodeUTF7Stateful(const char *s, Py_ssize_t size, const char *errors, Py_ssize_t *consumed)
     695
     696   If *consumed* is *NULL*, behave like :c:func:`PyUnicode_DecodeUTF7`.  If
     697   *consumed* is not *NULL*, trailing incomplete UTF-7 base-64 sections will not
     698   be treated as an error.  Those bytes will not be decoded and the number of
     699   bytes that have been decoded will be stored in *consumed*.
     700
     701
     702.. c:function:: PyObject* PyUnicode_EncodeUTF7(const Py_UNICODE *s, Py_ssize_t size, int base64SetO, int base64WhiteSpace, const char *errors)
     703
     704   Encode the :c:type:`Py_UNICODE` buffer of the given size using UTF-7 and
     705   return a Python bytes object.  Return *NULL* if an exception was raised by
     706   the codec.
     707
     708   If *base64SetO* is nonzero, "Set O" (punctuation that has no otherwise
     709   special meaning) will be encoded in base-64.  If *base64WhiteSpace* is
     710   nonzero, whitespace will be encoded in base-64.  Both are set to zero for the
     711   Python "utf-7" codec.
     712
     713
     714Unicode-Escape Codecs
     715"""""""""""""""""""""
     716
    555717These are the "Unicode Escape" codec APIs:
    556718
    557 .. % --- Unicode-Escape Codecs ----------------------------------------------
    558 
    559 
    560 .. cfunction:: PyObject* PyUnicode_DecodeUnicodeEscape(const char *s, Py_ssize_t size, const char *errors)
     719
     720.. c:function:: PyObject* PyUnicode_DecodeUnicodeEscape(const char *s, Py_ssize_t size, const char *errors)
    561721
    562722   Create a Unicode object by decoding *size* bytes of the Unicode-Escape encoded
     
    564724
    565725   .. versionchanged:: 2.5
    566       This function used an :ctype:`int` type for *size*. This might require
    567       changes in your code for properly supporting 64-bit systems.
    568 
    569 
    570 .. cfunction:: PyObject* PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size)
    571 
    572    Encode the :ctype:`Py_UNICODE` buffer of the given size using Unicode-Escape and
     726      This function used an :c:type:`int` type for *size*. This might require
     727      changes in your code for properly supporting 64-bit systems.
     728
     729
     730.. c:function:: PyObject* PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size)
     731
     732   Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Unicode-Escape and
    573733   return a Python string object.  Return *NULL* if an exception was raised by the
    574734   codec.
    575735
    576736   .. versionchanged:: 2.5
    577       This function used an :ctype:`int` type for *size*. This might require
    578       changes in your code for properly supporting 64-bit systems.
    579 
    580 
    581 .. cfunction:: PyObject* PyUnicode_AsUnicodeEscapeString(PyObject *unicode)
     737      This function used an :c:type:`int` type for *size*. This might require
     738      changes in your code for properly supporting 64-bit systems.
     739
     740
     741.. c:function:: PyObject* PyUnicode_AsUnicodeEscapeString(PyObject *unicode)
    582742
    583743   Encode a Unicode object using Unicode-Escape and return the result as Python
     
    585745   raised by the codec.
    586746
     747
     748Raw-Unicode-Escape Codecs
     749"""""""""""""""""""""""""
     750
    587751These are the "Raw Unicode Escape" codec APIs:
    588752
    589 .. % --- Raw-Unicode-Escape Codecs ------------------------------------------
    590 
    591 
    592 .. cfunction:: PyObject* PyUnicode_DecodeRawUnicodeEscape(const char *s, Py_ssize_t size, const char *errors)
     753
     754.. c:function:: PyObject* PyUnicode_DecodeRawUnicodeEscape(const char *s, Py_ssize_t size, const char *errors)
    593755
    594756   Create a Unicode object by decoding *size* bytes of the Raw-Unicode-Escape
     
    596758
    597759   .. versionchanged:: 2.5
    598       This function used an :ctype:`int` type for *size*. This might require
    599       changes in your code for properly supporting 64-bit systems.
    600 
    601 
    602 .. cfunction:: PyObject* PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
    603 
    604    Encode the :ctype:`Py_UNICODE` buffer of the given size using Raw-Unicode-Escape
     760      This function used an :c:type:`int` type for *size*. This might require
     761      changes in your code for properly supporting 64-bit systems.
     762
     763
     764.. c:function:: PyObject* PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
     765
     766   Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Raw-Unicode-Escape
    605767   and return a Python string object.  Return *NULL* if an exception was raised by
    606768   the codec.
    607769
    608770   .. versionchanged:: 2.5
    609       This function used an :ctype:`int` type for *size*. This might require
    610       changes in your code for properly supporting 64-bit systems.
    611 
    612 
    613 .. cfunction:: PyObject* PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode)
     771      This function used an :c:type:`int` type for *size*. This might require
     772      changes in your code for properly supporting 64-bit systems.
     773
     774
     775.. c:function:: PyObject* PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode)
    614776
    615777   Encode a Unicode object using Raw-Unicode-Escape and return the result as
     
    617779   was raised by the codec.
    618780
     781
     782Latin-1 Codecs
     783""""""""""""""
     784
    619785These are the Latin-1 codec APIs: Latin-1 corresponds to the first 256 Unicode
    620786ordinals and only these are accepted by the codecs during encoding.
    621787
    622 .. % --- Latin-1 Codecs -----------------------------------------------------
    623 
    624 
    625 .. cfunction:: PyObject* PyUnicode_DecodeLatin1(const char *s, Py_ssize_t size, const char *errors)
     788
     789.. c:function:: PyObject* PyUnicode_DecodeLatin1(const char *s, Py_ssize_t size, const char *errors)
    626790
    627791   Create a Unicode object by decoding *size* bytes of the Latin-1 encoded string
     
    629793
    630794   .. versionchanged:: 2.5
    631       This function used an :ctype:`int` type for *size*. This might require
    632       changes in your code for properly supporting 64-bit systems.
    633 
    634 
    635 .. cfunction:: PyObject* PyUnicode_EncodeLatin1(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
    636 
    637    Encode the :ctype:`Py_UNICODE` buffer of the given size using Latin-1 and return
     795      This function used an :c:type:`int` type for *size*. This might require
     796      changes in your code for properly supporting 64-bit systems.
     797
     798
     799.. c:function:: PyObject* PyUnicode_EncodeLatin1(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
     800
     801   Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Latin-1 and return
    638802   a Python string object.  Return *NULL* if an exception was raised by the codec.
    639803
    640804   .. versionchanged:: 2.5
    641       This function used an :ctype:`int` type for *size*. This might require
    642       changes in your code for properly supporting 64-bit systems.
    643 
    644 
    645 .. cfunction:: PyObject* PyUnicode_AsLatin1String(PyObject *unicode)
     805      This function used an :c:type:`int` type for *size*. This might require
     806      changes in your code for properly supporting 64-bit systems.
     807
     808
     809.. c:function:: PyObject* PyUnicode_AsLatin1String(PyObject *unicode)
    646810
    647811   Encode a Unicode object using Latin-1 and return the result as Python string
     
    649813   by the codec.
    650814
     815
     816ASCII Codecs
     817""""""""""""
     818
    651819These are the ASCII codec APIs.  Only 7-bit ASCII data is accepted. All other
    652820codes generate errors.
    653821
    654 .. % --- ASCII Codecs -------------------------------------------------------
    655 
    656 
    657 .. cfunction:: PyObject* PyUnicode_DecodeASCII(const char *s, Py_ssize_t size, const char *errors)
     822
     823.. c:function:: PyObject* PyUnicode_DecodeASCII(const char *s, Py_ssize_t size, const char *errors)
    658824
    659825   Create a Unicode object by decoding *size* bytes of the ASCII encoded string
     
    661827
    662828   .. versionchanged:: 2.5
    663       This function used an :ctype:`int` type for *size*. This might require
    664       changes in your code for properly supporting 64-bit systems.
    665 
    666 
    667 .. cfunction:: PyObject* PyUnicode_EncodeASCII(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
    668 
    669    Encode the :ctype:`Py_UNICODE` buffer of the given size using ASCII and return a
     829      This function used an :c:type:`int` type for *size*. This might require
     830      changes in your code for properly supporting 64-bit systems.
     831
     832
     833.. c:function:: PyObject* PyUnicode_EncodeASCII(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
     834
     835   Encode the :c:type:`Py_UNICODE` buffer of the given *size* using ASCII and return a
    670836   Python string object.  Return *NULL* if an exception was raised by the codec.
    671837
    672838   .. versionchanged:: 2.5
    673       This function used an :ctype:`int` type for *size*. This might require
    674       changes in your code for properly supporting 64-bit systems.
    675 
    676 
    677 .. cfunction:: PyObject* PyUnicode_AsASCIIString(PyObject *unicode)
     839      This function used an :c:type:`int` type for *size*. This might require
     840      changes in your code for properly supporting 64-bit systems.
     841
     842
     843.. c:function:: PyObject* PyUnicode_AsASCIIString(PyObject *unicode)
    678844
    679845   Encode a Unicode object using ASCII and return the result as Python string
     
    681847   by the codec.
    682848
    683 These are the mapping codec APIs:
    684 
    685 .. % --- Character Map Codecs -----------------------------------------------
     849
     850Character Map Codecs
     851""""""""""""""""""""
    686852
    687853This codec is special in that it can be used to implement many different codecs
     
    706872characters to different code points.
    707873
    708 
    709 .. cfunction:: PyObject* PyUnicode_DecodeCharmap(const char *s, Py_ssize_t size, PyObject *mapping, const char *errors)
     874These are the mapping codec APIs:
     875
     876.. c:function:: PyObject* PyUnicode_DecodeCharmap(const char *s, Py_ssize_t size, PyObject *mapping, const char *errors)
    710877
    711878   Create a Unicode object by decoding *size* bytes of the encoded string *s* using
     
    720887
    721888   .. versionchanged:: 2.5
    722       This function used an :ctype:`int` type for *size*. This might require
    723       changes in your code for properly supporting 64-bit systems.
    724 
    725 
    726 .. cfunction:: PyObject* PyUnicode_EncodeCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *mapping, const char *errors)
    727 
    728    Encode the :ctype:`Py_UNICODE` buffer of the given size using the given
     889      This function used an :c:type:`int` type for *size*. This might require
     890      changes in your code for properly supporting 64-bit systems.
     891
     892
     893.. c:function:: PyObject* PyUnicode_EncodeCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *mapping, const char *errors)
     894
     895   Encode the :c:type:`Py_UNICODE` buffer of the given *size* using the given
    729896   *mapping* object and return a Python string object. Return *NULL* if an
    730897   exception was raised by the codec.
    731898
    732899   .. versionchanged:: 2.5
    733       This function used an :ctype:`int` type for *size*. This might require
    734       changes in your code for properly supporting 64-bit systems.
    735 
    736 
    737 .. cfunction:: PyObject* PyUnicode_AsCharmapString(PyObject *unicode, PyObject *mapping)
     900      This function used an :c:type:`int` type for *size*. This might require
     901      changes in your code for properly supporting 64-bit systems.
     902
     903
     904.. c:function:: PyObject* PyUnicode_AsCharmapString(PyObject *unicode, PyObject *mapping)
    738905
    739906   Encode a Unicode object using the given *mapping* object and return the result
     
    744911
    745912
    746 .. cfunction:: PyObject* PyUnicode_TranslateCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *table, const char *errors)
    747 
    748    Translate a :ctype:`Py_UNICODE` buffer of the given length by applying a
     913.. c:function:: PyObject* PyUnicode_TranslateCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *table, const char *errors)
     914
     915   Translate a :c:type:`Py_UNICODE` buffer of the given *size* by applying a
    749916   character mapping *table* to it and return the resulting Unicode object.  Return
    750917   *NULL* when an exception was raised by the codec.
     
    758925
    759926   .. versionchanged:: 2.5
    760       This function used an :ctype:`int` type for *size*. This might require
    761       changes in your code for properly supporting 64-bit systems.
     927      This function used an :c:type:`int` type for *size*. This might require
     928      changes in your code for properly supporting 64-bit systems.
     929
     930
     931MBCS codecs for Windows
     932"""""""""""""""""""""""
    762933
    763934These are the MBCS codec APIs. They are currently only available on Windows and
     
    766937the user settings on the machine running the codec.
    767938
    768 .. % --- MBCS codecs for Windows --------------------------------------------
    769 
    770 
    771 .. cfunction:: PyObject* PyUnicode_DecodeMBCS(const char *s, Py_ssize_t size, const char *errors)
     939
     940.. c:function:: PyObject* PyUnicode_DecodeMBCS(const char *s, Py_ssize_t size, const char *errors)
    772941
    773942   Create a Unicode object by decoding *size* bytes of the MBCS encoded string *s*.
     
    775944
    776945   .. versionchanged:: 2.5
    777       This function used an :ctype:`int` type for *size*. This might require
    778       changes in your code for properly supporting 64-bit systems.
    779 
    780 
    781 .. cfunction:: PyObject* PyUnicode_DecodeMBCSStateful(const char *s, int size, const char *errors, int *consumed)
    782 
    783    If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeMBCS`. If
    784    *consumed* is not *NULL*, :cfunc:`PyUnicode_DecodeMBCSStateful` will not decode
     946      This function used an :c:type:`int` type for *size*. This might require
     947      changes in your code for properly supporting 64-bit systems.
     948
     949
     950.. c:function:: PyObject* PyUnicode_DecodeMBCSStateful(const char *s, int size, const char *errors, int *consumed)
     951
     952   If *consumed* is *NULL*, behave like :c:func:`PyUnicode_DecodeMBCS`. If
     953   *consumed* is not *NULL*, :c:func:`PyUnicode_DecodeMBCSStateful` will not decode
    785954   trailing lead byte and the number of bytes that have been decoded will be stored
    786955   in *consumed*.
     
    789958
    790959
    791 .. cfunction:: PyObject* PyUnicode_EncodeMBCS(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
    792 
    793    Encode the :ctype:`Py_UNICODE` buffer of the given size using MBCS and return a
     960.. c:function:: PyObject* PyUnicode_EncodeMBCS(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
     961
     962   Encode the :c:type:`Py_UNICODE` buffer of the given *size* using MBCS and return a
    794963   Python string object.  Return *NULL* if an exception was raised by the codec.
    795964
    796965   .. versionchanged:: 2.5
    797       This function used an :ctype:`int` type for *size*. This might require
    798       changes in your code for properly supporting 64-bit systems.
    799 
    800 
    801 .. cfunction:: PyObject* PyUnicode_AsMBCSString(PyObject *unicode)
     966      This function used an :c:type:`int` type for *size*. This might require
     967      changes in your code for properly supporting 64-bit systems.
     968
     969
     970.. c:function:: PyObject* PyUnicode_AsMBCSString(PyObject *unicode)
    802971
    803972   Encode a Unicode object using MBCS and return the result as Python string
     
    805974   by the codec.
    806975
    807 .. % --- Methods & Slots ----------------------------------------------------
    808 
     976
     977Methods & Slots
     978"""""""""""""""
    809979
    810980.. _unicodemethodsandslots:
     
    820990
    821991
    822 .. cfunction:: PyObject* PyUnicode_Concat(PyObject *left, PyObject *right)
     992.. c:function:: PyObject* PyUnicode_Concat(PyObject *left, PyObject *right)
    823993
    824994   Concat two strings giving a new Unicode string.
    825995
    826996
    827 .. cfunction:: PyObject* PyUnicode_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit)
    828 
    829    Split a string giving a list of Unicode strings.  If sep is *NULL*, splitting
     997.. c:function:: PyObject* PyUnicode_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit)
     998
     999   Split a string giving a list of Unicode strings.  If *sep* is *NULL*, splitting
    8301000   will be done at all whitespace substrings.  Otherwise, splits occur at the given
    8311001   separator.  At most *maxsplit* splits will be done.  If negative, no limit is
     
    8331003
    8341004   .. versionchanged:: 2.5
    835       This function used an :ctype:`int` type for *maxsplit*. This might require
    836       changes in your code for properly supporting 64-bit systems.
    837 
    838 
    839 .. cfunction:: PyObject* PyUnicode_Splitlines(PyObject *s, int keepend)
     1005      This function used an :c:type:`int` type for *maxsplit*. This might require
     1006      changes in your code for properly supporting 64-bit systems.
     1007
     1008
     1009.. c:function:: PyObject* PyUnicode_Splitlines(PyObject *s, int keepend)
    8401010
    8411011   Split a Unicode string at line breaks, returning a list of Unicode strings.
     
    8441014
    8451015
    846 .. cfunction:: PyObject* PyUnicode_Translate(PyObject *str, PyObject *table, const char *errors)
     1016.. c:function:: PyObject* PyUnicode_Translate(PyObject *str, PyObject *table, const char *errors)
    8471017
    8481018   Translate a string by applying a character mapping table to it and return the
     
    8601030
    8611031
    862 .. cfunction:: PyObject* PyUnicode_Join(PyObject *separator, PyObject *seq)
    863 
    864    Join a sequence of strings using the given separator and return the resulting
     1032.. c:function:: PyObject* PyUnicode_Join(PyObject *separator, PyObject *seq)
     1033
     1034   Join a sequence of strings using the given *separator* and return the resulting
    8651035   Unicode string.
    8661036
    8671037
    868 .. cfunction:: int PyUnicode_Tailmatch(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction)
    869 
    870    Return 1 if *substr* matches *str*[*start*:*end*] at the given tail end
     1038.. c:function:: int PyUnicode_Tailmatch(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction)
     1039
     1040   Return 1 if *substr* matches ``str[start:end]`` at the given tail end
    8711041   (*direction* == -1 means to do a prefix match, *direction* == 1 a suffix match),
    8721042   0 otherwise. Return ``-1`` if an error occurred.
    8731043
    8741044   .. versionchanged:: 2.5
    875       This function used an :ctype:`int` type for *start* and *end*. This
     1045      This function used an :c:type:`int` type for *start* and *end*. This
    8761046      might require changes in your code for properly supporting 64-bit
    8771047      systems.
    8781048
    8791049
    880 .. cfunction:: Py_ssize_t PyUnicode_Find(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction)
    881 
    882    Return the first position of *substr* in *str*[*start*:*end*] using the given
     1050.. c:function:: Py_ssize_t PyUnicode_Find(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction)
     1051
     1052   Return the first position of *substr* in ``str[start:end]`` using the given
    8831053   *direction* (*direction* == 1 means to do a forward search, *direction* == -1 a
    8841054   backward search).  The return value is the index of the first match; a value of
     
    8871057
    8881058   .. versionchanged:: 2.5
    889       This function used an :ctype:`int` type for *start* and *end*. This
     1059      This function used an :c:type:`int` type for *start* and *end*. This
    8901060      might require changes in your code for properly supporting 64-bit
    8911061      systems.
    8921062
    8931063
    894 .. cfunction:: Py_ssize_t PyUnicode_Count(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end)
     1064.. c:function:: Py_ssize_t PyUnicode_Count(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end)
    8951065
    8961066   Return the number of non-overlapping occurrences of *substr* in
     
    8981068
    8991069   .. versionchanged:: 2.5
    900       This function returned an :ctype:`int` type and used an :ctype:`int`
     1070      This function returned an :c:type:`int` type and used an :c:type:`int`
    9011071      type for *start* and *end*. This might require changes in your code for
    9021072      properly supporting 64-bit systems.
    9031073
    9041074
    905 .. cfunction:: PyObject* PyUnicode_Replace(PyObject *str, PyObject *substr, PyObject *replstr, Py_ssize_t maxcount)
     1075.. c:function:: PyObject* PyUnicode_Replace(PyObject *str, PyObject *substr, PyObject *replstr, Py_ssize_t maxcount)
    9061076
    9071077   Replace at most *maxcount* occurrences of *substr* in *str* with *replstr* and
     
    9101080
    9111081   .. versionchanged:: 2.5
    912       This function used an :ctype:`int` type for *maxcount*. This might
     1082      This function used an :c:type:`int` type for *maxcount*. This might
    9131083      require changes in your code for properly supporting 64-bit systems.
    9141084
    9151085
    916 .. cfunction:: int PyUnicode_Compare(PyObject *left, PyObject *right)
     1086.. c:function:: int PyUnicode_Compare(PyObject *left, PyObject *right)
    9171087
    9181088   Compare two strings and return -1, 0, 1 for less than, equal, and greater than,
     
    9201090
    9211091
    922 .. cfunction:: int PyUnicode_RichCompare(PyObject *left,  PyObject *right,  int op)
     1092.. c:function:: int PyUnicode_RichCompare(PyObject *left,  PyObject *right,  int op)
    9231093
    9241094   Rich compare two unicode strings and return one of the following:
     
    9361106
    9371107
    938 .. cfunction:: PyObject* PyUnicode_Format(PyObject *format, PyObject *args)
     1108.. c:function:: PyObject* PyUnicode_Format(PyObject *format, PyObject *args)
    9391109
    9401110   Return a new string object from *format* and *args*; this is analogous to
     
    9421112
    9431113
    944 .. cfunction:: int PyUnicode_Contains(PyObject *container, PyObject *element)
     1114.. c:function:: int PyUnicode_Contains(PyObject *container, PyObject *element)
    9451115
    9461116   Check whether *element* is contained in *container* and return true or false
  • python/vendor/current/Doc/c-api/utilities.rst

    r2 r388  
    2020   conversion.rst
    2121   reflection.rst
     22   codec.rst
  • python/vendor/current/Doc/c-api/veryhigh.rst

    r2 r388  
    1717following the functions which accept them as parameters.
    1818
    19 Note also that several of these functions take :ctype:`FILE\*` parameters.  One
    20 particular issue which needs to be handled carefully is that the :ctype:`FILE`
     19Note also that several of these functions take :c:type:`FILE\*` parameters.  One
     20particular issue which needs to be handled carefully is that the :c:type:`FILE`
    2121structure for different C libraries can be different and incompatible.  Under
    2222Windows (at least), it is possible for dynamically linked extensions to actually
    23 use different libraries, so care should be taken that :ctype:`FILE\*` parameters
     23use different libraries, so care should be taken that :c:type:`FILE\*` parameters
    2424are only passed to these functions if it is certain that they were created by
    2525the same library that the Python runtime is using.
    2626
    2727
    28 .. cfunction:: int Py_Main(int argc, char **argv)
     28.. c:function:: int Py_Main(int argc, char **argv)
    2929
    3030   The main program for the standard interpreter.  This is made available for
    3131   programs which embed Python.  The *argc* and *argv* parameters should be
    32    prepared exactly as those which are passed to a C program's :cfunc:`main`
     32   prepared exactly as those which are passed to a C program's :c:func:`main`
    3333   function.  It is important to note that the argument list may be modified (but
    3434   the contents of the strings pointed to by the argument list are not). The return
    35    value will be the integer passed to the :func:`sys.exit` function, ``1`` if the
    36    interpreter exits due to an exception, or ``2`` if the parameter list does not
    37    represent a valid Python command line.
    38 
    39    Note that if an otherwise unhandled :exc:`SystemError` is raised, this
     35   value will be ``0`` if the interpreter exits normally (ie, without an
     36   exception), ``1`` if the interpreter exits due to an exception, or ``2``
     37   if the parameter list does not represent a valid Python command line.
     38
     39   Note that if an otherwise unhandled :exc:`SystemExit` is raised, this
    4040   function will not return ``1``, but exit the process, as long as
    4141   ``Py_InspectFlag`` is not set.
    4242
    4343
    44 .. cfunction:: int PyRun_AnyFile(FILE *fp, const char *filename)
    45 
    46    This is a simplified interface to :cfunc:`PyRun_AnyFileExFlags` below, leaving
     44.. c:function:: int PyRun_AnyFile(FILE *fp, const char *filename)
     45
     46   This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, leaving
    4747   *closeit* set to ``0`` and *flags* set to *NULL*.
    4848
    4949
    50 .. cfunction:: int PyRun_AnyFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
    51 
    52    This is a simplified interface to :cfunc:`PyRun_AnyFileExFlags` below, leaving
     50.. c:function:: int PyRun_AnyFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
     51
     52   This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, leaving
    5353   the *closeit* argument set to ``0``.
    5454
    5555
    56 .. cfunction:: int PyRun_AnyFileEx(FILE *fp, const char *filename, int closeit)
    57 
    58    This is a simplified interface to :cfunc:`PyRun_AnyFileExFlags` below, leaving
     56.. c:function:: int PyRun_AnyFileEx(FILE *fp, const char *filename, int closeit)
     57
     58   This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, leaving
    5959   the *flags* argument set to *NULL*.
    6060
    6161
    62 .. cfunction:: int PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags)
     62.. c:function:: int PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags)
    6363
    6464   If *fp* refers to a file associated with an interactive device (console or
    6565   terminal input or Unix pseudo-terminal), return the value of
    66    :cfunc:`PyRun_InteractiveLoop`, otherwise return the result of
    67    :cfunc:`PyRun_SimpleFile`.  If *filename* is *NULL*, this function uses
     66   :c:func:`PyRun_InteractiveLoop`, otherwise return the result of
     67   :c:func:`PyRun_SimpleFile`.  If *filename* is *NULL*, this function uses
    6868   ``"???"`` as the filename.
    6969
    7070
    71 .. cfunction:: int PyRun_SimpleString(const char *command)
    72 
    73    This is a simplified interface to :cfunc:`PyRun_SimpleStringFlags` below,
     71.. c:function:: int PyRun_SimpleString(const char *command)
     72
     73   This is a simplified interface to :c:func:`PyRun_SimpleStringFlags` below,
    7474   leaving the *PyCompilerFlags\** argument set to NULL.
    7575
    7676
    77 .. cfunction:: int PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags)
     77.. c:function:: int PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags)
    7878
    7979   Executes the Python source code from *command* in the :mod:`__main__` module
     
    8383   meaning of *flags*, see below.
    8484
    85    Note that if an otherwise unhandled :exc:`SystemError` is raised, this
     85   Note that if an otherwise unhandled :exc:`SystemExit` is raised, this
    8686   function will not return ``-1``, but exit the process, as long as
    8787   ``Py_InspectFlag`` is not set.
    8888
    8989
    90 .. cfunction:: int PyRun_SimpleFile(FILE *fp, const char *filename)
    91 
    92    This is a simplified interface to :cfunc:`PyRun_SimpleFileExFlags` below,
     90.. c:function:: int PyRun_SimpleFile(FILE *fp, const char *filename)
     91
     92   This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below,
    9393   leaving *closeit* set to ``0`` and *flags* set to *NULL*.
    9494
    9595
    96 .. cfunction:: int PyRun_SimpleFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
    97 
    98    This is a simplified interface to :cfunc:`PyRun_SimpleFileExFlags` below,
     96.. c:function:: int PyRun_SimpleFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
     97
     98   This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below,
    9999   leaving *closeit* set to ``0``.
    100100
    101101
    102 .. cfunction:: int PyRun_SimpleFileEx(FILE *fp, const char *filename, int closeit)
    103 
    104    This is a simplified interface to :cfunc:`PyRun_SimpleFileExFlags` below,
     102.. c:function:: int PyRun_SimpleFileEx(FILE *fp, const char *filename, int closeit)
     103
     104   This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below,
    105105   leaving *flags* set to *NULL*.
    106106
    107107
    108 .. cfunction:: int PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags)
    109 
    110    Similar to :cfunc:`PyRun_SimpleStringFlags`, but the Python source code is read
     108.. c:function:: int PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags)
     109
     110   Similar to :c:func:`PyRun_SimpleStringFlags`, but the Python source code is read
    111111   from *fp* instead of an in-memory string. *filename* should be the name of the
    112112   file.  If *closeit* is true, the file is closed before PyRun_SimpleFileExFlags
     
    114114
    115115
    116 .. cfunction:: int PyRun_InteractiveOne(FILE *fp, const char *filename)
    117 
    118    This is a simplified interface to :cfunc:`PyRun_InteractiveOneFlags` below,
     116.. c:function:: int PyRun_InteractiveOne(FILE *fp, const char *filename)
     117
     118   This is a simplified interface to :c:func:`PyRun_InteractiveOneFlags` below,
    119119   leaving *flags* set to *NULL*.
    120120
    121121
    122 .. cfunction:: int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
    123 
    124    Read and execute a single statement from a file associated with an interactive
    125    device according to the *flags* argument.  If *filename* is *NULL*, ``"???"`` is
    126    used instead.  The user will be prompted using ``sys.ps1`` and ``sys.ps2``.
    127    Returns ``0`` when the input was executed successfully, ``-1`` if there was an
    128    exception, or an error code from the :file:`errcode.h` include file distributed
    129    as part of Python if there was a parse error.  (Note that :file:`errcode.h` is
    130    not included by :file:`Python.h`, so must be included specifically if needed.)
    131 
    132 
    133 .. cfunction:: int PyRun_InteractiveLoop(FILE *fp, const char *filename)
    134 
    135    This is a simplified interface to :cfunc:`PyRun_InteractiveLoopFlags` below,
     122.. c:function:: int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
     123
     124   Read and execute a single statement from a file associated with an
     125   interactive device according to the *flags* argument.  The user will be
     126   prompted using ``sys.ps1`` and ``sys.ps2``.  Returns ``0`` when the input was
     127   executed successfully, ``-1`` if there was an exception, or an error code
     128   from the :file:`errcode.h` include file distributed as part of Python if
     129   there was a parse error.  (Note that :file:`errcode.h` is not included by
     130   :file:`Python.h`, so must be included specifically if needed.)
     131
     132
     133.. c:function:: int PyRun_InteractiveLoop(FILE *fp, const char *filename)
     134
     135   This is a simplified interface to :c:func:`PyRun_InteractiveLoopFlags` below,
    136136   leaving *flags* set to *NULL*.
    137137
    138138
    139 .. cfunction:: int PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
     139.. c:function:: int PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
    140140
    141141   Read and execute statements from a file associated with an interactive device
    142    until EOF is reached.  If *filename* is *NULL*, ``"???"`` is used instead.  The
    143    user will be prompted using ``sys.ps1`` and ``sys.ps2``.  Returns ``0`` at EOF.
    144 
    145 
    146 .. cfunction:: struct _node* PyParser_SimpleParseString(const char *str, int start)
     142   until EOF is reached.  The user will be prompted using ``sys.ps1`` and
     143   ``sys.ps2``.  Returns ``0`` at EOF.
     144
     145
     146.. c:function:: struct _node* PyParser_SimpleParseString(const char *str, int start)
    147147
    148148   This is a simplified interface to
    149    :cfunc:`PyParser_SimpleParseStringFlagsFilename` below, leaving  *filename* set
     149   :c:func:`PyParser_SimpleParseStringFlagsFilename` below, leaving  *filename* set
    150150   to *NULL* and *flags* set to ``0``.
    151151
    152152
    153 .. cfunction:: struct _node* PyParser_SimpleParseStringFlags( const char *str, int start, int flags)
     153.. c:function:: struct _node* PyParser_SimpleParseStringFlags( const char *str, int start, int flags)
    154154
    155155   This is a simplified interface to
    156    :cfunc:`PyParser_SimpleParseStringFlagsFilename` below, leaving  *filename* set
     156   :c:func:`PyParser_SimpleParseStringFlagsFilename` below, leaving  *filename* set
    157157   to *NULL*.
    158158
    159159
    160 .. cfunction:: struct _node* PyParser_SimpleParseStringFlagsFilename( const char *str, const char *filename, int start, int flags)
     160.. c:function:: struct _node* PyParser_SimpleParseStringFlagsFilename( const char *str, const char *filename, int start, int flags)
    161161
    162162   Parse Python source code from *str* using the start token *start* according to
     
    166166
    167167
    168 .. cfunction:: struct _node* PyParser_SimpleParseFile(FILE *fp, const char *filename, int start)
    169 
    170    This is a simplified interface to :cfunc:`PyParser_SimpleParseFileFlags` below,
     168.. c:function:: struct _node* PyParser_SimpleParseFile(FILE *fp, const char *filename, int start)
     169
     170   This is a simplified interface to :c:func:`PyParser_SimpleParseFileFlags` below,
    171171   leaving *flags* set to ``0``
    172172
    173173
    174 .. cfunction:: struct _node* PyParser_SimpleParseFileFlags(FILE *fp, const char *filename, int start, int flags)
    175 
    176    Similar to :cfunc:`PyParser_SimpleParseStringFlagsFilename`, but the Python
     174.. c:function:: struct _node* PyParser_SimpleParseFileFlags(FILE *fp, const char *filename, int start, int flags)
     175
     176   Similar to :c:func:`PyParser_SimpleParseStringFlagsFilename`, but the Python
    177177   source code is read from *fp* instead of an in-memory string.
    178178
    179179
    180 .. cfunction:: PyObject* PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals)
    181 
    182    This is a simplified interface to :cfunc:`PyRun_StringFlags` below, leaving
     180.. c:function:: PyObject* PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals)
     181
     182   This is a simplified interface to :c:func:`PyRun_StringFlags` below, leaving
    183183   *flags* set to *NULL*.
    184184
    185185
    186 .. cfunction:: PyObject* PyRun_StringFlags(const char *str, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags)
     186.. c:function:: PyObject* PyRun_StringFlags(const char *str, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags)
    187187
    188188   Execute Python source code from *str* in the context specified by the
     
    195195
    196196
    197 .. cfunction:: PyObject* PyRun_File(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals)
    198 
    199    This is a simplified interface to :cfunc:`PyRun_FileExFlags` below, leaving
     197.. c:function:: PyObject* PyRun_File(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals)
     198
     199   This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving
    200200   *closeit* set to ``0`` and *flags* set to *NULL*.
    201201
    202202
    203 .. cfunction:: PyObject* PyRun_FileEx(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit)
    204 
    205    This is a simplified interface to :cfunc:`PyRun_FileExFlags` below, leaving
     203.. c:function:: PyObject* PyRun_FileEx(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit)
     204
     205   This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving
    206206   *flags* set to *NULL*.
    207207
    208208
    209 .. cfunction:: PyObject* PyRun_FileFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags)
    210 
    211    This is a simplified interface to :cfunc:`PyRun_FileExFlags` below, leaving
     209.. c:function:: PyObject* PyRun_FileFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags)
     210
     211   This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving
    212212   *closeit* set to ``0``.
    213213
    214214
    215 .. cfunction:: PyObject* PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit, PyCompilerFlags *flags)
    216 
    217    Similar to :cfunc:`PyRun_StringFlags`, but the Python source code is read from
     215.. c:function:: PyObject* PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit, PyCompilerFlags *flags)
     216
     217   Similar to :c:func:`PyRun_StringFlags`, but the Python source code is read from
    218218   *fp* instead of an in-memory string. *filename* should be the name of the file.
    219    If *closeit* is true, the file is closed before :cfunc:`PyRun_FileExFlags`
     219   If *closeit* is true, the file is closed before :c:func:`PyRun_FileExFlags`
    220220   returns.
    221221
    222222
    223 .. cfunction:: PyObject* Py_CompileString(const char *str, const char *filename, int start)
    224 
    225    This is a simplified interface to :cfunc:`Py_CompileStringFlags` below, leaving
     223.. c:function:: PyObject* Py_CompileString(const char *str, const char *filename, int start)
     224
     225   This is a simplified interface to :c:func:`Py_CompileStringFlags` below, leaving
    226226   *flags* set to *NULL*.
    227227
    228228
    229 .. cfunction:: PyObject* Py_CompileStringFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags)
     229.. c:function:: PyObject* Py_CompileStringFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags)
    230230
    231231   Parse and compile the Python source code in *str*, returning the resulting code
     
    238238
    239239
    240 .. cfunction:: PyObject* PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals)
    241 
    242    This is a simplified interface to :cfunc:`PyEval_EvalCodeEx`, with just
     240.. c:function:: PyObject* PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals)
     241
     242   This is a simplified interface to :c:func:`PyEval_EvalCodeEx`, with just
    243243   the code object, and the dictionaries of global and local variables.
    244244   The other arguments are set to *NULL*.
    245245
    246246
    247 .. cfunction:: PyObject* PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, PyObject **defs, int defcount, PyObject *closure)
     247.. c:function:: PyObject* PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, PyObject **defs, int defcount, PyObject *closure)
    248248
    249249   Evaluate a precompiled code object, given a particular environment for its
     
    253253
    254254
    255 .. cfunction:: PyObject* PyEval_EvalFrame(PyFrameObject *f)
     255.. c:function:: PyObject* PyEval_EvalFrame(PyFrameObject *f)
    256256
    257257   Evaluate an execution frame.  This is a simplified interface to
     
    259259
    260260
    261 .. cfunction:: PyObject* PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
     261.. c:function:: PyObject* PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
    262262
    263263   This is the main, unvarnished function of Python interpretation.  It is
     
    266266   The additional *throwflag* parameter can mostly be ignored - if true, then
    267267   it causes an exception to immediately be thrown; this is used for the
    268    :meth:`throw` methods of generator objects.
    269 
    270 
    271 .. cfunction:: int PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
     268   :meth:`~generator.throw` methods of generator objects.
     269
     270
     271.. c:function:: int PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
    272272
    273273   This function changes the flags of the current evaluation frame, and returns
     
    275275
    276276
    277 .. cvar:: int Py_eval_input
     277.. c:var:: int Py_eval_input
    278278
    279279   .. index:: single: Py_CompileString()
    280280
    281281   The start symbol from the Python grammar for isolated expressions; for use with
    282    :cfunc:`Py_CompileString`.
    283 
    284 
    285 .. cvar:: int Py_file_input
     282   :c:func:`Py_CompileString`.
     283
     284
     285.. c:var:: int Py_file_input
    286286
    287287   .. index:: single: Py_CompileString()
    288288
    289289   The start symbol from the Python grammar for sequences of statements as read
    290    from a file or other source; for use with :cfunc:`Py_CompileString`.  This is
     290   from a file or other source; for use with :c:func:`Py_CompileString`.  This is
    291291   the symbol to use when compiling arbitrarily long Python source code.
    292292
    293293
    294 .. cvar:: int Py_single_input
     294.. c:var:: int Py_single_input
    295295
    296296   .. index:: single: Py_CompileString()
    297297
    298298   The start symbol from the Python grammar for a single statement; for use with
    299    :cfunc:`Py_CompileString`. This is the symbol used for the interactive
     299   :c:func:`Py_CompileString`. This is the symbol used for the interactive
    300300   interpreter loop.
    301301
    302302
    303 .. ctype:: struct PyCompilerFlags
     303.. c:type:: struct PyCompilerFlags
    304304
    305305   This is the structure used to hold compiler flags.  In cases where code is only
     
    317317
    318318
    319 .. cvar:: int CO_FUTURE_DIVISION
     319.. c:var:: int CO_FUTURE_DIVISION
    320320
    321321   This bit can be set in *flags* to cause division operator ``/`` to be
  • python/vendor/current/Doc/c-api/weakref.rst

    r2 r388  
    1212
    1313
    14 .. cfunction:: int PyWeakref_Check(ob)
     14.. c:function:: int PyWeakref_Check(ob)
    1515
    1616   Return true if *ob* is either a reference or proxy object.
     
    1919
    2020
    21 .. cfunction:: int PyWeakref_CheckRef(ob)
     21.. c:function:: int PyWeakref_CheckRef(ob)
    2222
    2323   Return true if *ob* is a reference object.
     
    2626
    2727
    28 .. cfunction:: int PyWeakref_CheckProxy(ob)
     28.. c:function:: int PyWeakref_CheckProxy(ob)
    2929
    3030   Return true if *ob* is a proxy object.
     
    3333
    3434
    35 .. cfunction:: PyObject* PyWeakref_NewRef(PyObject *ob, PyObject *callback)
     35.. c:function:: PyObject* PyWeakref_NewRef(PyObject *ob, PyObject *callback)
    3636
    3737   Return a weak reference object for the object *ob*.  This will always return
     
    4747
    4848
    49 .. cfunction:: PyObject* PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
     49.. c:function:: PyObject* PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
    5050
    5151   Return a weak reference proxy object for the object *ob*.  This will always
     
    6161
    6262
    63 .. cfunction:: PyObject* PyWeakref_GetObject(PyObject *ref)
     63.. c:function:: PyObject* PyWeakref_GetObject(PyObject *ref)
    6464
    6565   Return the referenced object from a weak reference, *ref*.  If the referent is
    66    no longer live, returns ``None``.
     66   no longer live, returns :const:`Py_None`.
    6767
    6868   .. versionadded:: 2.2
    6969
     70   .. warning::
    7071
    71 .. cfunction:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
     72      This function returns a **borrowed reference** to the referenced object.
     73      This means that you should always call :c:func:`Py_INCREF` on the object
     74      except if you know that it cannot be destroyed while you are still
     75      using it.
    7276
    73    Similar to :cfunc:`PyWeakref_GetObject`, but implemented as a macro that does no
     77
     78.. c:function:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
     79
     80   Similar to :c:func:`PyWeakref_GetObject`, but implemented as a macro that does no
    7481   error checking.
    7582
Note: See TracChangeset for help on using the changeset viewer.