]> granicus.if.org Git - python/commitdiff
make sure to initialize the method wrapper type
authorBenjamin Peterson <benjamin@python.org>
Thu, 1 Sep 2011 20:32:31 +0000 (16:32 -0400)
committerBenjamin Peterson <benjamin@python.org>
Thu, 1 Sep 2011 20:32:31 +0000 (16:32 -0400)
Include/descrobject.h
Objects/descrobject.c
Objects/object.c

index f715fe116012ea7ba3cc480a1ec5d97ce0fa6384..646b3cca4e43e4f90814e95fd0cb20a5e6967f48 100644 (file)
@@ -77,6 +77,7 @@ PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
 PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
 PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
 PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
+PyAPI_DATA(PyTypeObject) _PyMethodWrapper_Type;
 
 PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
 PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
index 93daefd75f8563e3896ea2e8c0ed44eb758d5715..a786bae14343c113f1acb859dcecf5fe1f3b732d 100644 (file)
@@ -846,16 +846,13 @@ PyDictProxy_New(PyObject *dict)
 /* This has no reason to be in this file except that adding new files is a
    bit of a pain */
 
-/* forward */
-static PyTypeObject wrappertype;
-
 typedef struct {
     PyObject_HEAD
     PyWrapperDescrObject *descr;
     PyObject *self;
 } wrapperobject;
 
-#define Wrapper_Check(v) (Py_TYPE(v) == &wrappertype)
+#define Wrapper_Check(v) (Py_TYPE(v) == &_PyMethodWrapper_Type)
 
 static void
 wrapper_dealloc(wrapperobject *wp)
@@ -1021,7 +1018,7 @@ wrapper_traverse(PyObject *self, visitproc visit, void *arg)
     return 0;
 }
 
-static PyTypeObject wrappertype = {
+PyTypeObject _PyMethodWrapper_Type = {
     PyVarObject_HEAD_INIT(&PyType_Type, 0)
     "method-wrapper",                           /* tp_name */
     sizeof(wrapperobject),                      /* tp_basicsize */
@@ -1070,7 +1067,7 @@ PyWrapper_New(PyObject *d, PyObject *self)
     assert(_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
                                     (PyObject *)PyDescr_TYPE(descr)));
 
-    wp = PyObject_GC_New(wrapperobject, &wrappertype);
+    wp = PyObject_GC_New(wrapperobject, &_PyMethodWrapper_Type);
     if (wp != NULL) {
         Py_INCREF(descr);
         wp->descr = descr;
index 3240bc37be4a7f8ef397201c5eafc25d7cd74597..694e7e719e94b2bac449e16c8abc387ff0fea1e7 100644 (file)
@@ -1625,6 +1625,9 @@ _Py_ReadyTypes(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(&PyEllipsis_Type) < 0)
         Py_FatalError("Can't initialize ellipsis type");