PEP 3123: Provide forward compatibility with Python 3.0, while keeping

backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
This commit is contained in:
Martin v. Löwis 2007-07-21 06:55:02 +00:00
parent b1994b4a5d
commit 6819210b9e
129 changed files with 1090 additions and 1250 deletions

View file

@ -544,8 +544,7 @@ func_descr_get(PyObject *func, PyObject *obj, PyObject *type)
}
PyTypeObject PyFunction_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"function",
sizeof(PyFunctionObject),
0,
@ -615,7 +614,7 @@ cm_dealloc(classmethod *cm)
{
_PyObject_GC_UNTRACK((PyObject *)cm);
Py_XDECREF(cm->cm_callable);
cm->ob_type->tp_free((PyObject *)cm);
Py_Type(cm)->tp_free((PyObject *)cm);
}
static int
@ -644,9 +643,9 @@ cm_descr_get(PyObject *self, PyObject *obj, PyObject *type)
return NULL;
}
if (type == NULL)
type = (PyObject *)(obj->ob_type);
type = (PyObject *)(Py_Type(obj));
return PyMethod_New(cm->cm_callable,
type, (PyObject *)(type->ob_type));
type, (PyObject *)(Py_Type(type)));
}
static int
@ -692,8 +691,7 @@ Class methods are different than C++ or Java static methods.\n\
If you want those, see the staticmethod builtin.");
PyTypeObject PyClassMethod_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"classmethod",
sizeof(classmethod),
0,
@ -773,7 +771,7 @@ sm_dealloc(staticmethod *sm)
{
_PyObject_GC_UNTRACK((PyObject *)sm);
Py_XDECREF(sm->sm_callable);
sm->ob_type->tp_free((PyObject *)sm);
Py_Type(sm)->tp_free((PyObject *)sm);
}
static int
@ -840,8 +838,7 @@ Static methods in Python are similar to those found in Java or C++.\n\
For a more advanced concept, see the classmethod builtin.");
PyTypeObject PyStaticMethod_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"staticmethod",
sizeof(staticmethod),
0,