[Python-checkins] r70842 - python/trunk/Doc/c-api/object.rst

georg.brandl python-checkins at python.org
Tue Mar 31 19:13:06 CEST 2009


Author: georg.brandl
Date: Tue Mar 31 19:13:06 2009
New Revision: 70842
Log:
#970783: document PyObject_Generic[GS]etAttr.
Modified:
 python/trunk/Doc/c-api/object.rst
Modified: python/trunk/Doc/c-api/object.rst
==============================================================================
--- python/trunk/Doc/c-api/object.rst	(original)
+++ python/trunk/Doc/c-api/object.rst	Tue Mar 31 19:13:06 2009
@@ -42,6 +42,16 @@
 expression ``o.attr_name``.
 
 
+.. cfunction:: PyObject* PyObject_GenericGetAttr(PyObject *o, PyObject *name)
+
+ Generic attribute getter function that is meant to be put into a type
+ object's ``tp_getattro`` slot. It looks for a descriptor in the dictionary
+ of classes in the object's MRO as well as an attribute in the object's
+ :attr:`__dict__` (if present). As outlined in :ref:`descriptors`, data
+ descriptors take preference over instance attributes, while non-data
+ descriptors don't. Otherwise, an :exc:`AttributeError` is raised.
+
+
 .. cfunction:: 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
@@ -56,6 +66,17 @@
 ``o.attr_name = v``.
 
 
+.. cfunction:: int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject
+*value)
+
+ Generic attribute setter function that is meant to be put into a type
+ object's ``tp_setattro`` slot. It looks for a data descriptor in the
+ dictionary of classes in the object's MRO, and if found it takes preference
+ over setting the attribute in the instance dictionary. Otherwise, the
+ attribute is set in the object's :attr:`__dict__` (if present). Otherwise,
+ an :exc:`AttributeError` is raised and ``-1`` is returned.
+
+
 .. cfunction:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name)
 
 Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on failure.


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /