cpython: 50711c80ff76 (original) (raw)

Mercurial > cpython

changeset 99504:50711c80ff76 3.5

Issue #25701: Document C API functions that both set and delete objects Also document that the separate functions that delete objects are preferred; using PyObject_SetAttr(), _SetAttrString(), and PySequence_SetItem() to delete is deprecated. [#25701]

Martin Panter vadmium+py@gmail.com
date Tue, 08 Dec 2015 00:03:20 +0000
parents e10e3fd31726
children 7bb7173cd97a 1d0d8b27a4e6
files Doc/c-api/object.rst Doc/c-api/sequence.rst Doc/c-api/typeobj.rst Include/abstract.h
diffstat 4 files changed, 50 insertions(+), 29 deletions(-)[+] [-] Doc/c-api/object.rst 27 Doc/c-api/sequence.rst 6 Doc/c-api/typeobj.rst 26 Include/abstract.h 20

line wrap: on

line diff

--- a/Doc/c-api/object.rst +++ b/Doc/c-api/object.rst @@ -68,25 +68,35 @@ Object Protocol .. c:function:: int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v) Set the value of the attribute named attr_name, for object o, to the value

.. c:function:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v) Set the value of the attribute named attr_name, for object o, to the value

.. c:function:: int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value)

.. c:function:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name) @@ -378,7 +388,8 @@ Object Protocol .. c:function:: int PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v)

--- a/Doc/c-api/sequence.rst +++ b/Doc/c-api/sequence.rst @@ -62,10 +62,14 @@ Sequence Protocol .. c:function:: int PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v)

.. c:function:: int PySequence_DelItem(PyObject *o, Py_ssize_t i)

--- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -208,12 +208,13 @@ type objects) must have the :attr:`ob_ .. c:member:: setattrfunc PyTypeObject.tp_setattr

.. c:member:: setattrofunc PyTypeObject.tp_setattro

@@ -724,7 +726,7 @@ type objects) must have the :attr:`ob_ typedef struct PyGetSetDef { char name; / attribute name / getter get; / C function to get the attribute */

@@ -775,12 +777,14 @@ type objects) must have the :attr:`ob_ .. c:member:: descrsetfunc PyTypeObject.tp_descr_set

.. c:member:: objobjargproc PyMappingMethods.mp_ass_subscript

.. _sequence-structs: @@ -1222,7 +1228,7 @@ Sequence Object Structures This function is used by :c:func:PySequence_SetItem and has the same signature. This slot may be left to NULL if the object does not support

.. c:member:: objobjproc PySequenceMethods.sq_contains

--- a/Include/abstract.h +++ b/Include/abstract.h @@ -192,8 +192,8 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v); Set the value of the attribute named attr_name, for object o,

*/ @@ -202,8 +202,8 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v); Set the value of the attribute named attr_name, for object o,

*/ @@ -435,9 +435,9 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx PyAPI_FUNC(int) PyObject_SetItem(PyObject *o, PyObject *key, PyObject v); /

PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, const char *key); @@ -993,9 +993,9 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject v); /

PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i);