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/object.rst

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