diff -r 57bf7a40925f Include/descrobject.h --- a/Include/descrobject.h Sat Apr 30 21:56:59 2016 -0500 +++ b/Include/descrobject.h Mon May 02 17:44:54 2016 +0300 @@ -67,10 +67,13 @@ typedef struct { void *d_wrapped; /* This can be any function pointer */ } PyWrapperDescrObject; +PyAPI_DATA(PyTypeObject) _PyClassMethodDescr_Type; +PyAPI_DATA(PyTypeObject) _PyMethodDescr_Type; PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type; PyAPI_DATA(PyTypeObject) PyDictProxy_Type; PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type; PyAPI_DATA(PyTypeObject) PyMemberDescr_Type; +PyAPI_DATA(PyTypeObject) _PyMethodWrapper_Type; PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *); PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *); diff -r 57bf7a40925f Objects/descrobject.c --- a/Objects/descrobject.c Sat Apr 30 21:56:59 2016 -0500 +++ b/Objects/descrobject.c Mon May 02 17:44:54 2016 +0300 @@ -420,7 +420,7 @@ descr_traverse(PyObject *self, visitproc return 0; } -static PyTypeObject PyMethodDescr_Type = { +PyTypeObject _PyMethodDescr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "method_descriptor", sizeof(PyMethodDescrObject), @@ -458,7 +458,7 @@ static PyTypeObject PyMethodDescr_Type = }; /* This is for METH_CLASS in C, not for "f = classmethod(f)" in Python! */ -static PyTypeObject PyClassMethodDescr_Type = { +PyTypeObject _PyClassMethodDescr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "classmethod_descriptor", sizeof(PyMethodDescrObject), @@ -629,7 +629,7 @@ PyDescr_NewMethod(PyTypeObject *type, Py { PyMethodDescrObject *descr; - descr = (PyMethodDescrObject *)descr_new(&PyMethodDescr_Type, + descr = (PyMethodDescrObject *)descr_new(&_PyMethodDescr_Type, type, method->ml_name); if (descr != NULL) descr->d_method = method; @@ -641,7 +641,7 @@ PyDescr_NewClassMethod(PyTypeObject *typ { PyMethodDescrObject *descr; - descr = (PyMethodDescrObject *)descr_new(&PyClassMethodDescr_Type, + descr = (PyMethodDescrObject *)descr_new(&_PyClassMethodDescr_Type, type, method->ml_name); if (descr != NULL) descr->d_method = method; @@ -1053,7 +1053,7 @@ wrapper_traverse(PyObject *self, visitpr return 0; } -static PyTypeObject wrappertype = { +PyTypeObject _PyMethodWrapper_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "method-wrapper", /* tp_name */ sizeof(wrapperobject), /* tp_basicsize */ @@ -1102,7 +1102,7 @@ PyWrapper_New(PyObject *d, PyObject *sel assert(_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self), (PyObject *)(descr->d_type))); - wp = PyObject_GC_New(wrapperobject, &wrappertype); + wp = PyObject_GC_New(wrapperobject, &_PyMethodWrapper_Type); if (wp != NULL) { Py_INCREF(descr); wp->descr = descr; diff -r 57bf7a40925f Objects/object.c --- a/Objects/object.c Sat Apr 30 21:56:59 2016 -0500 +++ b/Objects/object.c Mon May 02 17:44:54 2016 +0300 @@ -2192,6 +2192,9 @@ void if (PyType_Ready(&PyWrapperDescr_Type) < 0) Py_FatalError("Can't initialize wrapper type"); + if (PyType_Ready(&_PyMethodWrapper_Type) < 0) + Py_FatalError("Can't initialize method wrapper type"); + if (PyType_Ready(&PyInstance_Type) < 0) Py_FatalError("Can't initialize instance type"); @@ -2210,6 +2213,12 @@ void if (PyType_Ready(&PyCell_Type) < 0) Py_FatalError("Can't initialize cell type"); + if (PyType_Ready(&_PyClassMethodDescr_Type) < 0) + Py_FatalError("Can't initialize class method descr type"); + + if (PyType_Ready(&_PyMethodDescr_Type) < 0) + Py_FatalError("Can't initialize method descr type"); + if (PyType_Ready(&PyCallIter_Type) < 0) Py_FatalError("Can't initialize call iter type");