Index: Include/descrobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/descrobject.h,v retrieving revision 2.11 diff -c -r2.11 descrobject.h *** Include/descrobject.h 19 Aug 2002 18:45:37 -0000 2.11 --- Include/descrobject.h 6 Dec 2002 18:41:41 -0000 *************** *** 70,75 **** --- 70,76 ---- PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type; PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *); + PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *); PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, struct PyMemberDef *); PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, Index: Objects/descrobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/descrobject.c,v retrieving revision 2.31 diff -c -r2.31 descrobject.c *** Objects/descrobject.c 31 Aug 2002 15:51:04 -0000 2.31 --- Objects/descrobject.c 6 Dec 2002 18:41:41 -0000 *************** *** 79,84 **** --- 79,90 ---- } static PyObject * + classmethod_get(PyMethodDescrObject *descr, PyObject *obj, PyTypeObject *type) + { + return PyCFunction_New(descr->d_method, (PyObject *)type); + } + + static PyObject * method_get(PyMethodDescrObject *descr, PyObject *obj, PyTypeObject *type) { PyObject *res; *************** *** 213,218 **** --- 219,238 ---- } static PyObject * + classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args, PyObject *kwds) + { + PyObject *func, *result; + + func = PyCFunction_New(descr->d_method, (PyObject *)descr->d_type); + if (func == NULL) + return NULL; + + result = PyEval_CallObjectWithKeywords(func, args, kwds); + Py_DECREF(func); + return result; + } + + static PyObject * wrapperdescr_call(PyWrapperDescrObject *descr, PyObject *args, PyObject *kwds) { int argc; *************** *** 373,378 **** --- 393,436 ---- 0, /* tp_descr_set */ }; + static PyTypeObject PyClassMethodDescr_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "special_method_descriptor", + sizeof(PyMethodDescrObject), + 0, + (destructor)descr_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc)method_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)classmethoddescr_call, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + 0, /* tp_doc */ + descr_traverse, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + descr_members, /* tp_members */ + method_getset, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + (descrgetfunc)classmethod_get, /* tp_descr_get */ + 0, /* tp_descr_set */ + }; + static PyTypeObject PyMemberDescr_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, *************** *** 511,516 **** --- 569,586 ---- PyMethodDescrObject *descr; descr = (PyMethodDescrObject *)descr_new(&PyMethodDescr_Type, + type, method->ml_name); + if (descr != NULL) + descr->d_method = method; + return (PyObject *)descr; + } + + PyObject * + PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method) + { + PyMethodDescrObject *descr; + + descr = (PyMethodDescrObject *)descr_new(&PyClassMethodDescr_Type, type, method->ml_name); if (descr != NULL) descr->d_method = method; Index: Objects/dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.134 diff -c -r2.134 dictobject.c *** Objects/dictobject.c 4 Dec 2002 07:32:25 -0000 2.134 --- Objects/dictobject.c 6 Dec 2002 18:41:42 -0000 *************** *** 963,979 **** } static PyObject * ! dict_fromkeys(PyObject *mp, PyObject *args) { PyObject *seq; PyObject *value = Py_None; PyObject *it; /* iter(seq) */ PyObject *key; PyObject *d; - PyObject *cls; int status; ! if (!PyArg_ParseTuple(args, "OO|O:fromkeys", &cls, &seq, &value)) return NULL; d = PyObject_CallObject(cls, NULL); --- 963,978 ---- } static PyObject * ! dict_fromkeys(PyObject *cls, PyObject *args) { PyObject *seq; PyObject *value = Py_None; PyObject *it; /* iter(seq) */ PyObject *key; PyObject *d; int status; ! if (!PyArg_ParseTuple(args, "O|O:fromkeys", &seq, &value)) return NULL; d = PyObject_CallObject(cls, NULL); Index: Objects/typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.194 diff -c -r2.194 typeobject.c *** Objects/typeobject.c 27 Nov 2002 16:29:25 -0000 2.194 --- Objects/typeobject.c 6 Dec 2002 18:41:42 -0000 *************** *** 2435,2441 **** "method cannot be both class and static"); return -1; } ! descr = create_specialmethod(meth, PyClassMethod_New); } else if (meth->ml_flags & METH_STATIC) { descr = create_specialmethod(meth, PyStaticMethod_New); --- 2435,2441 ---- "method cannot be both class and static"); return -1; } ! descr = PyDescr_NewClassMethod(type, meth); } else if (meth->ml_flags & METH_STATIC) { descr = create_specialmethod(meth, PyStaticMethod_New);