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

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

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

    r2 r391  
    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.
Note: See TracChangeset for help on using the changeset viewer.