mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
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:
parent
b1994b4a5d
commit
6819210b9e
129 changed files with 1090 additions and 1250 deletions
|
@ -72,7 +72,7 @@ typedef struct {
|
|||
|
||||
|
||||
#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 @@ get_pylong(PyObject *v)
|
|||
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 @@ s_dealloc(PyStructObject *s)
|
|||
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 PyGetSetDef s_getsetlist[] = {
|
|||
|
||||
static
|
||||
PyTypeObject PyStructType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"Struct",
|
||||
sizeof(PyStructObject),
|
||||
0,
|
||||
|
@ -1857,7 +1856,7 @@ init_struct(void)
|
|||
if (m == NULL)
|
||||
return;
|
||||
|
||||
PyStructType.ob_type = &PyType_Type;
|
||||
Py_Type(&PyStructType) = &PyType_Type;
|
||||
if (PyType_Ready(&PyStructType) < 0)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue