mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	make sure to initialize the method wrapper type
This commit is contained in:
		
							parent
							
								
									a762285831
								
							
						
					
					
						commit
						eff61f6927
					
				
					 3 changed files with 7 additions and 6 deletions
				
			
		| 
						 | 
					@ -77,6 +77,7 @@ PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
 | 
				
			||||||
PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
 | 
					PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
 | 
				
			||||||
PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
 | 
					PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
 | 
				
			||||||
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
 | 
					PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
 | 
				
			||||||
 | 
					PyAPI_DATA(PyTypeObject) _PyMethodWrapper_Type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
 | 
					PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
 | 
				
			||||||
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
 | 
					PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -846,16 +846,13 @@ PyDictProxy_New(PyObject *dict)
 | 
				
			||||||
/* This has no reason to be in this file except that adding new files is a
 | 
					/* This has no reason to be in this file except that adding new files is a
 | 
				
			||||||
   bit of a pain */
 | 
					   bit of a pain */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* forward */
 | 
					 | 
				
			||||||
static PyTypeObject wrappertype;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
    PyObject_HEAD
 | 
					    PyObject_HEAD
 | 
				
			||||||
    PyWrapperDescrObject *descr;
 | 
					    PyWrapperDescrObject *descr;
 | 
				
			||||||
    PyObject *self;
 | 
					    PyObject *self;
 | 
				
			||||||
} wrapperobject;
 | 
					} wrapperobject;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define Wrapper_Check(v) (Py_TYPE(v) == &wrappertype)
 | 
					#define Wrapper_Check(v) (Py_TYPE(v) == &_PyMethodWrapper_Type)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
wrapper_dealloc(wrapperobject *wp)
 | 
					wrapper_dealloc(wrapperobject *wp)
 | 
				
			||||||
| 
						 | 
					@ -1021,7 +1018,7 @@ wrapper_traverse(PyObject *self, visitproc visit, void *arg)
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static PyTypeObject wrappertype = {
 | 
					PyTypeObject _PyMethodWrapper_Type = {
 | 
				
			||||||
    PyVarObject_HEAD_INIT(&PyType_Type, 0)
 | 
					    PyVarObject_HEAD_INIT(&PyType_Type, 0)
 | 
				
			||||||
    "method-wrapper",                           /* tp_name */
 | 
					    "method-wrapper",                           /* tp_name */
 | 
				
			||||||
    sizeof(wrapperobject),                      /* tp_basicsize */
 | 
					    sizeof(wrapperobject),                      /* tp_basicsize */
 | 
				
			||||||
| 
						 | 
					@ -1070,7 +1067,7 @@ PyWrapper_New(PyObject *d, PyObject *self)
 | 
				
			||||||
    assert(_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
 | 
					    assert(_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
 | 
				
			||||||
                                    (PyObject *)PyDescr_TYPE(descr)));
 | 
					                                    (PyObject *)PyDescr_TYPE(descr)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    wp = PyObject_GC_New(wrapperobject, &wrappertype);
 | 
					    wp = PyObject_GC_New(wrapperobject, &_PyMethodWrapper_Type);
 | 
				
			||||||
    if (wp != NULL) {
 | 
					    if (wp != NULL) {
 | 
				
			||||||
        Py_INCREF(descr);
 | 
					        Py_INCREF(descr);
 | 
				
			||||||
        wp->descr = descr;
 | 
					        wp->descr = descr;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1625,6 +1625,9 @@ _Py_ReadyTypes(void)
 | 
				
			||||||
    if (PyType_Ready(&PyWrapperDescr_Type) < 0)
 | 
					    if (PyType_Ready(&PyWrapperDescr_Type) < 0)
 | 
				
			||||||
        Py_FatalError("Can't initialize wrapper type");
 | 
					        Py_FatalError("Can't initialize wrapper type");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (PyType_Ready(&_PyMethodWrapper_Type) < 0)
 | 
				
			||||||
 | 
					        Py_FatalError("Can't initialize method wrapper type");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (PyType_Ready(&PyEllipsis_Type) < 0)
 | 
					    if (PyType_Ready(&PyEllipsis_Type) < 0)
 | 
				
			||||||
        Py_FatalError("Can't initialize ellipsis type");
 | 
					        Py_FatalError("Can't initialize ellipsis type");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue