[Python-checkins] CVS: python/dist/src/Include descrobject.h,1.1.2.6,1.1.2.7

Guido van Rossum gvanrossum@users.sourceforge.net
2001年7月09日 11:11:58 -0700


Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv18303/Include
Modified Files:
 Tag: descr-branch
	descrobject.h 
Log Message:
Total rewrite of the descriptor object implementation, to get rid of
the discriminated union. The ultimate goal here was to make the
definition of PyDescr_IsData() more reasonable: it not just tests
whether the type has a __set__ method (i.e. a tp_descr_set slot). If
it does, it's a data descriptor, otherwise it's not. This is
important when an attribute is found in both the __dict__ of the class
and the __dict__ of the instance: when the descriptor in the class is
a data descriptor, it has precedence, but when it is a non-data
(e.g. method) desscriptor, the instance __dict__ takes precedence.
Previously, this function had to have special dispensation to look
inside descriptor objects -- this is no longer necessary.
Note that the presence of a __set__ method doesn't mean that the
attribute can actually be assigned to: this is also used to make
attributes deliberately read-only, by making the __set__ method always
raise an exception. (Q: should it raise AttributeError or TypeError?
Traditionally, this has raised TypeError!)
Index: descrobject.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/Attic/descrobject.h,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -C2 -r1.1.2.6 -r1.1.2.7
*** descrobject.h	2001年05月01日 21:04:21	1.1.2.6
--- descrobject.h	2001年07月09日 18:11:56	1.1.2.7
***************
*** 1,3 ****
! /* XXX getter, setter, and struct getsetlist need 'Py'-prefixed names */
 
 typedef PyObject *(*getter)(PyObject *, void *);
--- 1,3 ----
! /* XXX getter, setter, getsetlist and wrapperbase need 'Py'-prefixed names */
 
 typedef PyObject *(*getter)(PyObject *, void *);
***************
*** 11,15 ****
 };
 
! typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args, void *wrapped);
 
 struct wrapperbase {
--- 11,16 ----
 };
 
! typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
! 				 void *wrapped);
 
 struct wrapperbase {
***************
*** 19,28 ****
 };
 
- extern PyTypeObject PyDescr_Type;
- 
- #define PyDescr_Check(d) ((d)->ob_type == &PyDescr_Type)
- 
- typedef struct PyDescrObject PyDescrObject;
- 
 extern DL_IMPORT(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
 extern DL_IMPORT(PyObject *) PyDescr_NewMember(PyTypeObject *,
--- 20,23 ----
***************
*** 32,38 ****
 extern DL_IMPORT(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
 						struct wrapperbase *, void *);
- extern DL_IMPORT(int) PyDescr_IsMethod(PyObject *);
 extern DL_IMPORT(int) PyDescr_IsData(PyObject *);
 
 extern DL_IMPORT(PyObject *) PyDictProxy_New(PyObject *);
! extern DL_IMPORT(PyObject *) PyWrapper_New(PyDescrObject *, PyObject *);
--- 27,32 ----
 extern DL_IMPORT(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
 						struct wrapperbase *, void *);
 extern DL_IMPORT(int) PyDescr_IsData(PyObject *);
 
 extern DL_IMPORT(PyObject *) PyDictProxy_New(PyObject *);
! extern DL_IMPORT(PyObject *) PyWrapper_New(PyObject *, PyObject *);

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