@@ -208,12 +208,13 @@ type objects) *must* have the :attr:`ob_size` field.
208
208
209
209
.. c :member :: setattrfunc PyTypeObject.tp_setattr
210
210
211
- An optional pointer to the set-attribute-string function.
211
+ An optional pointer to the function for setting and deleting attributes .
212
212
213
213
This field is deprecated. When it is defined, it should point to a function
214
214
that acts the same as the :c:member: `~PyTypeObject.tp_setattro ` function, but taking a C string
215
215
instead of a Python string object to give the attribute name. The signature is
216
- the same as for :c:func: `PyObject_SetAttrString `.
216
+ the same as for :c:func: `PyObject_SetAttrString `, but setting
217
+ *v * to *NULL * to delete an attribute must be supported.
217
218
218
219
This field is inherited by subtypes together with :c:member: `~PyTypeObject.tp_setattro `: a subtype
219
220
inherits both :c:member: `~PyTypeObject.tp_setattr ` and :c:member: `~PyTypeObject.tp_setattro ` from its base type when
@@ -351,9 +352,10 @@ type objects) *must* have the :attr:`ob_size` field.
351
352
352
353
.. c :member :: setattrofunc PyTypeObject.tp_setattro
353
354
354
- An optional pointer to the set-attribute function.
355
+ An optional pointer to the function for setting and deleting attributes .
355
356
356
- The signature is the same as for :c:func: `PyObject_SetAttr `. It is usually
357
+ The signature is the same as for :c:func: `PyObject_SetAttr `, but setting
358
+ *v * to *NULL * to delete an attribute must be supported. It is usually
357
359
convenient to set this field to :c:func: `PyObject_GenericSetAttr `, which
358
360
implements the normal way of setting object attributes.
359
361
@@ -724,7 +726,7 @@ type objects) *must* have the :attr:`ob_size` field.
724
726
typedef struct PyGetSetDef {
725
727
char *name; /* attribute name */
726
728
getter get; /* C function to get the attribute */
727
- setter set; /* C function to set the attribute */
729
+ setter set; /* C function to set or delete the attribute */
728
730
char *doc; /* optional doc string */
729
731
void *closure; /* optional additional data for getter and setter */
730
732
} PyGetSetDef;
@@ -775,12 +777,14 @@ type objects) *must* have the :attr:`ob_size` field.
775
777
776
778
.. c :member :: descrsetfunc PyTypeObject.tp_descr_set
777
779
778
- An optional pointer to a "descriptor set" function.
780
+ An optional pointer to a function for setting and deleting
781
+ a descriptor's value.
779
782
780
783
The function signature is ::
781
784
782
785
int tp_descr_set(PyObject *self, PyObject *obj, PyObject *value);
783
786
787
+ The *value * argument is set to *NULL * to delete the value.
784
788
This field is inherited by subtypes.
785
789
786
790
.. XXX explain.
@@ -1171,9 +1175,11 @@ Mapping Object Structures
1171
1175
1172
1176
.. c :member :: objobjargproc PyMappingMethods.mp_ass_subscript
1173
1177
1174
- This function is used by :c:func: `PyObject_SetItem ` and has the same
1175
- signature. If this slot is *NULL *, the object does not support item
1176
- assignment.
1178
+ This function is used by :c:func: `PyObject_SetItem ` and
1179
+ :c:func: `PyObject_DelItem `. It has the same signature as
1180
+ :c:func: `PyObject_SetItem `, but *v * can also be set to *NULL * to delete
1181
+ an item. If this slot is *NULL *, the object does not support item
1182
+ assignment and deletion.
1177
1183
1178
1184
1179
1185
.. _sequence-structs :
@@ -1222,7 +1228,7 @@ Sequence Object Structures
1222
1228
1223
1229
This function is used by :c:func: `PySequence_SetItem ` and has the same
1224
1230
signature. This slot may be left to *NULL * if the object does not support
1225
- item assignment.
1231
+ item assignment and deletion .
1226
1232
1227
1233
.. c :member :: objobjproc PySequenceMethods.sq_contains
1228
1234
0 commit comments