PEP 3123: Provide forward compatibility with Python 3.0, while keeping
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
diff --git a/Modules/_struct.c b/Modules/_struct.c
index ee938d6..36e64be 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -72,7 +72,7 @@
#define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStructType)
-#define PyStruct_CheckExact(op) ((op)->ob_type == &PyStructType)
+#define PyStruct_CheckExact(op) (Py_Type(op) == &PyStructType)
/* Exception */
@@ -133,7 +133,7 @@
Py_INCREF(v);
return v;
}
- m = v->ob_type->tp_as_number;
+ m = Py_Type(v)->tp_as_number;
if (m != NULL && m->nb_long != NULL) {
v = m->nb_long(v);
if (v == NULL)
@@ -1487,7 +1487,7 @@
PyMem_FREE(s->s_codes);
}
Py_XDECREF(s->s_format);
- s->ob_type->tp_free((PyObject *)s);
+ Py_Type(s)->tp_free((PyObject *)s);
}
static PyObject *
@@ -1806,8 +1806,7 @@
static
PyTypeObject PyStructType = {
- PyObject_HEAD_INIT(NULL)
- 0,
+ PyVarObject_HEAD_INIT(NULL, 0)
"Struct",
sizeof(PyStructObject),
0,
@@ -1857,7 +1856,7 @@
if (m == NULL)
return;
- PyStructType.ob_type = &PyType_Type;
+ Py_Type(&PyStructType) = &PyType_Type;
if (PyType_Ready(&PyStructType) < 0)
return;