diff options
Diffstat (limited to 'Modules')
59 files changed, 440 insertions, 548 deletions
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c index e71169c..0347907 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -300,13 +300,13 @@ staticforward PyTypeObject DBSequence_Type; staticforward PyTypeObject DB_Type, DBCursor_Type, DBEnv_Type, DBTxn_Type, DBLock_Type; -#define DBObject_Check(v) ((v)->ob_type == &DB_Type) -#define DBCursorObject_Check(v) ((v)->ob_type == &DBCursor_Type) -#define DBEnvObject_Check(v) ((v)->ob_type == &DBEnv_Type) -#define DBTxnObject_Check(v) ((v)->ob_type == &DBTxn_Type) -#define DBLockObject_Check(v) ((v)->ob_type == &DBLock_Type) +#define DBObject_Check(v) (Py_Type(v) == &DB_Type) +#define DBCursorObject_Check(v) (Py_Type(v) == &DBCursor_Type) +#define DBEnvObject_Check(v) (Py_Type(v) == &DBEnv_Type) +#define DBTxnObject_Check(v) (Py_Type(v) == &DBTxn_Type) +#define DBLockObject_Check(v) (Py_Type(v) == &DBLock_Type) #if (DBVER >= 43) -#define DBSequenceObject_Check(v) ((v)->ob_type == &DBSequence_Type) +#define DBSequenceObject_Check(v) (Py_Type(v) == &DBSequence_Type) #endif @@ -461,7 +461,7 @@ make_key_dbt(DBObject* self, PyObject* keyobj, DBT* key, int* pflags) else { PyErr_Format(PyExc_TypeError, "String or Integer object expected for key, %s found", - keyobj->ob_type->tp_name); + Py_Type(keyobj)->tp_name); return 0; } @@ -616,7 +616,7 @@ static int makeDBError(int err) static void makeTypeError(char* expected, PyObject* found) { PyErr_Format(PyExc_TypeError, "Expected %s argument, %s found.", - expected, found->ob_type->tp_name); + expected, Py_Type(found)->tp_name); } @@ -5666,13 +5666,13 @@ DL_EXPORT(void) init_bsddb(void) /* Initialize the type of the new type objects here; doing it here is required for portability to Windows without requiring C++. */ - DB_Type.ob_type = &PyType_Type; - DBCursor_Type.ob_type = &PyType_Type; - DBEnv_Type.ob_type = &PyType_Type; - DBTxn_Type.ob_type = &PyType_Type; - DBLock_Type.ob_type = &PyType_Type; + Py_Type(&DB_Type) = &PyType_Type; + Py_Type(&DBCursor_Type) = &PyType_Type; + Py_Type(&DBEnv_Type) = &PyType_Type; + Py_Type(&DBTxn_Type) = &PyType_Type; + Py_Type(&DBLock_Type) = &PyType_Type; #if (DBVER >= 43) - DBSequence_Type.ob_type = &PyType_Type; + Py_Type(&DBSequence_Type) = &PyType_Type; #endif diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index c70019c..7f5e2ae 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -544,7 +544,7 @@ deque_dealloc(dequeobject *deque) } deque->leftblock = NULL; deque->rightblock = NULL; - deque->ob_type->tp_free(deque); + Py_Type(deque)->tp_free(deque); } static int @@ -579,7 +579,7 @@ deque_nohash(PyObject *self) static PyObject * deque_copy(PyObject *deque) { - return PyObject_CallFunctionObjArgs((PyObject *)(deque->ob_type), + return PyObject_CallFunctionObjArgs((PyObject *)(Py_Type(deque)), deque, NULL); } @@ -601,7 +601,7 @@ deque_reduce(dequeobject *deque) Py_DECREF(dict); return NULL; } - result = Py_BuildValue("O()ON", deque->ob_type, dict, it); + result = Py_BuildValue("O()ON", Py_Type(deque), dict, it); Py_DECREF(dict); return result; } @@ -825,8 +825,7 @@ PyDoc_STRVAR(deque_doc, Build an ordered collection accessible from endpoints only."); static PyTypeObject deque_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "collections.deque", /* tp_name */ sizeof(dequeobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -903,7 +902,7 @@ static void dequeiter_dealloc(dequeiterobject *dio) { Py_XDECREF(dio->deque); - dio->ob_type->tp_free(dio); + Py_Type(dio)->tp_free(dio); } static PyObject * @@ -948,8 +947,7 @@ static PyMethodDef dequeiter_methods[] = { }; PyTypeObject dequeiter_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "deque_iterator", /* tp_name */ sizeof(dequeiterobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1031,8 +1029,7 @@ dequereviter_next(dequeiterobject *it) } PyTypeObject dequereviter_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "deque_reverse_iterator", /* tp_name */ sizeof(dequeiterobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1113,7 +1110,7 @@ defdict_copy(defdictobject *dd) whose class constructor has the same signature. Subclasses that define a different constructor signature must override copy(). */ - return PyObject_CallFunctionObjArgs((PyObject *)dd->dict.ob_type, + return PyObject_CallFunctionObjArgs(Py_Type(dd), dd->default_factory, dd, NULL); } @@ -1156,7 +1153,7 @@ defdict_reduce(defdictobject *dd) Py_DECREF(args); return NULL; } - result = PyTuple_Pack(5, dd->dict.ob_type, args, + result = PyTuple_Pack(5, Py_Type(dd), args, Py_None, Py_None, items); Py_DECREF(items); Py_DECREF(args); @@ -1288,8 +1285,7 @@ A defaultdict compares equal to a dict with the same items.\n\ #define DEFERRED_ADDRESS(ADDR) 0 static PyTypeObject defdict_type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "collections.defaultdict", /* tp_name */ sizeof(defdictobject), /* tp_basicsize */ 0, /* tp_itemsize */ diff --git a/Modules/_csv.c b/Modules/_csv.c index 5e03635..1bb8332 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -125,7 +125,7 @@ typedef struct { staticforward PyTypeObject Reader_Type; -#define ReaderObject_Check(v) ((v)->ob_type == &Reader_Type) +#define ReaderObject_Check(v) (Py_Type(v) == &Reader_Type) typedef struct { PyObject_HEAD @@ -310,7 +310,7 @@ static void Dialect_dealloc(DialectObj *self) { Py_XDECREF(self->lineterminator); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } static char *dialect_kws[] = { @@ -460,8 +460,7 @@ PyDoc_STRVAR(Dialect_Type_doc, "The Dialect type records CSV parsing and generation options.\n"); static PyTypeObject Dialect_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "_csv.Dialect", /* tp_name */ sizeof(DialectObj), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -869,8 +868,7 @@ static struct PyMemberDef Reader_memberlist[] = { static PyTypeObject Reader_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "_csv.reader", /*tp_name*/ sizeof(ReaderObj), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -1280,8 +1278,7 @@ PyDoc_STRVAR(Writer_Type_doc, ); static PyTypeObject Writer_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "_csv.writer", /*tp_name*/ sizeof(WriterObj), /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 8eeb865..020f473 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -333,7 +333,7 @@ CDataType_from_param(PyObject *type, PyObject *value) Py_INCREF(value); return value; } - ob_name = (ob) ? ob->ob_type->tp_name : "???"; + ob_name = (ob) ? Py_Type(ob)->tp_name : "???"; PyErr_Format(PyExc_TypeError, "expected %s instance instead of pointer to %s", ((PyTypeObject *)type)->tp_name, ob_name); @@ -349,7 +349,7 @@ CDataType_from_param(PyObject *type, PyObject *value) PyErr_Format(PyExc_TypeError, "expected %s instance instead of %s", ((PyTypeObject *)type)->tp_name, - value->ob_type->tp_name); + Py_Type(value)->tp_name); return NULL; } @@ -435,8 +435,7 @@ UnionType_setattro(PyObject *self, PyObject *key, PyObject *value) PyTypeObject StructType_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "_ctypes.StructType", /* tp_name */ 0, /* tp_basicsize */ 0, /* tp_itemsize */ @@ -478,8 +477,7 @@ PyTypeObject StructType_Type = { }; static PyTypeObject UnionType_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "_ctypes.UnionType", /* tp_name */ 0, /* tp_basicsize */ 0, /* tp_itemsize */ @@ -693,8 +691,7 @@ static PyMethodDef PointerType_methods[] = { }; PyTypeObject PointerType_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "_ctypes.PointerType", /* tp_name */ 0, /* tp_basicsize */ 0, /* tp_itemsize */ @@ -751,7 +748,7 @@ CharArray_set_raw(CDataObject *self, PyObject *value) char *ptr; Py_ssize_t size; if (PyBuffer_Check(value)) { - size = value->ob_type->tp_as_buffer->bf_getreadbuffer(value, 0, (void *)&ptr); + size = Py_Type(value)->tp_as_buffer->bf_getreadbuffer(value, 0, (void *)&ptr); if (size < 0) return -1; } else if (-1 == PyString_AsStringAndSize(value, &ptr, &size)) { @@ -800,7 +797,7 @@ CharArray_set_value(CDataObject *self, PyObject *value) } else if (!PyString_Check(value)) { PyErr_Format(PyExc_TypeError, "string expected instead of %s instance", - value->ob_type->tp_name); + Py_Type(value)->tp_name); return -1; } else Py_INCREF(value); @@ -855,7 +852,7 @@ WCharArray_set_value(CDataObject *self, PyObject *value) } else if (!PyUnicode_Check(value)) { PyErr_Format(PyExc_TypeError, "unicode string expected instead of %s instance", - value->ob_type->tp_name); + Py_Type(value)->tp_name); return -1; } else Py_INCREF(value); @@ -1051,8 +1048,7 @@ ArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } PyTypeObject ArrayType_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "_ctypes.ArrayType", /* tp_name */ 0, /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1684,8 +1680,7 @@ static PyMethodDef SimpleType_methods[] = { }; PyTypeObject SimpleType_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "_ctypes.SimpleType", /* tp_name */ 0, /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1899,8 +1894,7 @@ CFuncPtrType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } PyTypeObject CFuncPtrType_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "_ctypes.CFuncPtrType", /* tp_name */ 0, /* tp_basicsize */ 0, /* tp_itemsize */ @@ -2076,7 +2070,7 @@ static void CData_dealloc(PyObject *self) { CData_clear((CDataObject *)self); - self->ob_type->tp_free(self); + Py_Type(self)->tp_free(self); } static PyMemberDef CData_members[] = { @@ -2143,8 +2137,7 @@ static PyMethodDef CData_methods[] = { }; PyTypeObject CData_Type = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "_ctypes._CData", sizeof(CDataObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -2350,7 +2343,7 @@ _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value, PyErr_Format(PyExc_TypeError, "expected %s instance, got %s", ((PyTypeObject *)type)->tp_name, - value->ob_type->tp_name); + Py_Type(value)->tp_name); return NULL; } } @@ -2381,7 +2374,7 @@ _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value, if (p1->proto != p2->proto) { PyErr_Format(PyExc_TypeError, "incompatible types, %s instance instead of %s instance", - value->ob_type->tp_name, + Py_Type(value)->tp_name, ((PyTypeObject *)type)->tp_name); return NULL; } @@ -2400,7 +2393,7 @@ _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value, } PyErr_Format(PyExc_TypeError, "incompatible types, %s instance instead of %s instance", - value->ob_type->tp_name, + Py_Type(value)->tp_name, ((PyTypeObject *)type)->tp_name); return NULL; } @@ -2661,7 +2654,7 @@ _check_outarg_type(PyObject *arg, Py_ssize_t index) Py_SAFE_DOWNCAST(index, Py_ssize_t, int), PyType_Check(arg) ? ((PyTypeObject *)arg)->tp_name : - arg->ob_type->tp_name); + Py_Type(arg)->tp_name); return 0; } @@ -3447,7 +3440,7 @@ static void CFuncPtr_dealloc(CFuncPtrObject *self) { CFuncPtr_clear(self); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } static PyObject * @@ -3457,17 +3450,16 @@ CFuncPtr_repr(CFuncPtrObject *self) if (self->index) return PyString_FromFormat("<COM method offset %d: %s at %p>", self->index - 0x1000, - self->ob_type->tp_name, + Py_Type(self)->tp_name, self); #endif return PyString_FromFormat("<%s object at %p>", - self->ob_type->tp_name, + Py_Type(self)->tp_name, self); } PyTypeObject CFuncPtr_Type = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "_ctypes.CFuncPtr", sizeof(CFuncPtrObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -3595,8 +3587,7 @@ Struct_init(PyObject *self, PyObject *args, PyObject *kwds) } static PyTypeObject Struct_Type = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "_ctypes.Structure", sizeof(CDataObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -3638,8 +3629,7 @@ static PyTypeObject Struct_Type = { }; static PyTypeObject Union_Type = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "_ctypes.Union", sizeof(CDataObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -3871,8 +3861,7 @@ static PySequenceMethods Array_as_sequence = { }; PyTypeObject Array_Type = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "_ctypes.Array", sizeof(CDataObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -4025,7 +4014,7 @@ static PyGetSetDef Simple_getsets[] = { static PyObject * Simple_from_outparm(PyObject *self, PyObject *args) { - if (IsSimpleSubType((PyObject *)self->ob_type)) { + if (IsSimpleSubType((PyObject *)Py_Type(self))) { Py_INCREF(self); return self; } @@ -4090,9 +4079,9 @@ Simple_repr(CDataObject *self) PyObject *val, *name, *args, *result; static PyObject *format; - if (self->ob_type->tp_base != &Simple_Type) { + if (Py_Type(self)->tp_base != &Simple_Type) { return PyString_FromFormat("<%s object at %p>", - self->ob_type->tp_name, self); + Py_Type(self)->tp_name, self); } if (format == NULL) { @@ -4105,7 +4094,7 @@ Simple_repr(CDataObject *self) if (val == NULL) return NULL; - name = PyString_FromString(self->ob_type->tp_name); + name = PyString_FromString(Py_Type(self)->tp_name); if (name == NULL) { Py_DECREF(val); return NULL; @@ -4123,8 +4112,7 @@ Simple_repr(CDataObject *self) } static PyTypeObject Simple_Type = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "_ctypes._SimpleCData", sizeof(CDataObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -4277,7 +4265,7 @@ Pointer_set_contents(CDataObject *self, PyObject *value, void *closure) PyErr_Format(PyExc_TypeError, "expected %s instead of %s", ((PyTypeObject *)(stgdict->proto))->tp_name, - value->ob_type->tp_name); + Py_Type(value)->tp_name); return -1; } @@ -4406,8 +4394,7 @@ static PyNumberMethods Pointer_as_number = { }; PyTypeObject Pointer_Type = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "_ctypes._Pointer", sizeof(CDataObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -4585,7 +4572,7 @@ cast_check_pointertype(PyObject *arg) "cast() argument 2 must be a pointer type, not %s", PyType_Check(arg) ? ((PyTypeObject *)arg)->tp_name - : arg->ob_type->tp_name); + : Py_Type(arg)->tp_name); return 0; } @@ -4712,37 +4699,37 @@ init_ctypes(void) if (PyType_Ready(&CData_Type) < 0) return; - Struct_Type.ob_type = &StructType_Type; + Py_Type(&Struct_Type) = &StructType_Type; Struct_Type.tp_base = &CData_Type; if (PyType_Ready(&Struct_Type) < 0) return; PyModule_AddObject(m, "Structure", (PyObject *)&Struct_Type); - Union_Type.ob_type = &UnionType_Type; + Py_Type(&Union_Type) = &UnionType_Type; Union_Type.tp_base = &CData_Type; if (PyType_Ready(&Union_Type) < 0) return; PyModule_AddObject(m, "Union", (PyObject *)&Union_Type); - Pointer_Type.ob_type = &PointerType_Type; + Py_Type(&Pointer_Type) = &PointerType_Type; Pointer_Type.tp_base = &CData_Type; if (PyType_Ready(&Pointer_Type) < 0) return; PyModule_AddObject(m, "_Pointer", (PyObject *)&Pointer_Type); - Array_Type.ob_type = &ArrayType_Type; + Py_Type(&Array_Type) = &ArrayType_Type; Array_Type.tp_base = &CData_Type; if (PyType_Ready(&Array_Type) < 0) return; PyModule_AddObject(m, "Array", (PyObject *)&Array_Type); - Simple_Type.ob_type = &SimpleType_Type; + Py_Type(&Simple_Type) = &SimpleType_Type; Simple_Type.tp_base = &CData_Type; if (PyType_Ready(&Simple_Type) < 0) return; PyModule_AddObject(m, "_SimpleCData", (PyObject *)&Simple_Type); - CFuncPtr_Type.ob_type = &CFuncPtrType_Type; + Py_Type(&CFuncPtr_Type) = &CFuncPtrType_Type; CFuncPtr_Type.tp_base = &CData_Type; if (PyType_Ready(&CFuncPtr_Type) < 0) return; diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 7f95b9e..80d6dff 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -381,8 +381,7 @@ static PyMemberDef PyCArgType_members[] = { }; PyTypeObject PyCArg_Type = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "CArgObject", sizeof(PyCArgObject), 0, @@ -1180,7 +1179,7 @@ call_commethod(PyObject *self, PyObject *args) if (!CDataObject_Check(pcom) || (pcom->b_size != sizeof(void *))) { PyErr_Format(PyExc_TypeError, "COM Pointer expected instead of %s instance", - pcom->ob_type->tp_name); + Py_Type(pcom)->tp_name); return NULL; } @@ -1420,7 +1419,7 @@ byref(PyObject *self, PyObject *obj) if (!CDataObject_Check(obj)) { PyErr_Format(PyExc_TypeError, "byref() argument must be a ctypes instance, not '%s'", - obj->ob_type->tp_name); + Py_Type(obj)->tp_name); return NULL; } diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index ccdab0a..0e4c19e 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -286,8 +286,7 @@ CField_repr(CFieldObject *self) } PyTypeObject CField_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "_ctypes.CField", /* tp_name */ sizeof(CFieldObject), /* tp_basicsize */ 0, /* tp_itemsize */ diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index cfa72ef..a126eb7 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -83,8 +83,7 @@ StgDict_clone(StgDictObject *dst, StgDictObject *src) } PyTypeObject StgDict_Type = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "StgDict", sizeof(StgDictObject), 0, @@ -192,7 +191,7 @@ MakeFields(PyObject *type, CFieldObject *descr, Py_DECREF(fieldlist); return -1; } - if (fdescr->ob_type != &CField_Type) { + if (Py_Type(fdescr) != &CField_Type) { PyErr_SetString(PyExc_TypeError, "unexpected type"); Py_DECREF(fdescr); Py_DECREF(fieldlist); @@ -215,7 +214,7 @@ MakeFields(PyObject *type, CFieldObject *descr, Py_DECREF(fieldlist); return -1; } - assert(new_descr->ob_type == &CField_Type); + assert(Py_Type(new_descr) == &CField_Type); new_descr->size = fdescr->size; new_descr->offset = fdescr->offset + offset; new_descr->index = fdescr->index + index; @@ -263,7 +262,7 @@ MakeAnonFields(PyObject *type) Py_DECREF(anon_names); return -1; } - assert(descr->ob_type == &CField_Type); + assert(Py_Type(descr) == &CField_Type); descr->anonymous = 1; /* descr is in the field descriptor. */ diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 0acf3fd..5eb4cf8 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -56,7 +56,7 @@ typedef struct { PyTypeObject PyCursesPanel_Type; -#define PyCursesPanel_Check(v) ((v)->ob_type == &PyCursesPanel_Type) +#define PyCursesPanel_Check(v) (Py_Type(v) == &PyCursesPanel_Type) /* Some helper functions. The problem is that there's always a window associated with a panel. To ensure that Python's GC doesn't pull @@ -338,8 +338,7 @@ PyCursesPanel_GetAttr(PyCursesPanelObject *self, char *name) /* -------------------------------------------------------*/ PyTypeObject PyCursesPanel_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "_curses_panel.curses panel", /*tp_name*/ sizeof(PyCursesPanelObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -458,7 +457,7 @@ init_curses_panel(void) PyObject *m, *d, *v; /* Initialize object type */ - PyCursesPanel_Type.ob_type = &PyType_Type; + Py_Type(&PyCursesPanel_Type) = &PyType_Type; import_curses(); diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index 1ee407e..fa6548a 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -1566,8 +1566,7 @@ PyCursesWindow_GetAttr(PyCursesWindowObject *self, char *name) /* -------------------------------------------------------*/ PyTypeObject PyCursesWindow_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "_curses.curses window", /*tp_name*/ sizeof(PyCursesWindowObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -2657,7 +2656,7 @@ init_curses(void) static void *PyCurses_API[PyCurses_API_pointers]; /* Initialize object type */ - PyCursesWindow_Type.ob_type = &PyType_Type; + Py_Type(&PyCursesWindow_Type) = &PyType_Type; /* Initialize the C API pointer array */ PyCurses_API[0] = (void *)&PyCursesWindow_Type; diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index f21cf56..d8a28b4 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -269,7 +269,7 @@ typedef struct { staticforward PyTypeObject Element_Type; -#define Element_CheckExact(op) ((op)->ob_type == &Element_Type) +#define Element_CheckExact(op) (Py_Type(op) == &Element_Type) /* -------------------------------------------------------------------- */ /* element constructor and destructor */ @@ -1207,7 +1207,7 @@ element_setslice(PyObject* self_, Py_ssize_t start, Py_ssize_t end, PyObject* it /* FIXME: support arbitrary sequences? */ PyErr_Format( PyExc_TypeError, - "expected list, not \"%.200s\"", item->ob_type->tp_name + "expected list, not \"%.200s\"", Py_Type(item)->tp_name ); return -1; } @@ -1440,7 +1440,7 @@ typedef struct { staticforward PyTypeObject TreeBuilder_Type; -#define TreeBuilder_CheckExact(op) ((op)->ob_type == &TreeBuilder_Type) +#define TreeBuilder_CheckExact(op) (Py_Type(op) == &TreeBuilder_Type) /* -------------------------------------------------------------------- */ /* constructor and destructor */ @@ -1607,7 +1607,7 @@ treebuilder_handle_data(TreeBuilderObject* self, PyObject* data) Py_INCREF(data); self->data = data; } else { /* more than one item; use a list to collect items */ - if (PyString_CheckExact(self->data) && self->data->ob_refcnt == 1 && + if (PyString_CheckExact(self->data) && Py_Refcnt(self->data) == 1 && PyString_CheckExact(data) && PyString_GET_SIZE(data) == 1) { /* expat often generates single character data sections; handle the most common case by resizing the existing string... */ @@ -2623,9 +2623,9 @@ init_elementtree(void) #endif /* Patch object type */ - Element_Type.ob_type = TreeBuilder_Type.ob_type = &PyType_Type; + Py_Type(&Element_Type) = Py_Type(&TreeBuilder_Type) = &PyType_Type; #if defined(USE_EXPAT) - XMLParser_Type.ob_type = &PyType_Type; + Py_Type(&XMLParser_Type) = &PyType_Type; #endif m = Py_InitModule("_elementtree", _functions); diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 54abb89..96bdc20 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -81,7 +81,7 @@ partial_dealloc(partialobject *pto) Py_XDECREF(pto->args); Py_XDECREF(pto->kw); Py_XDECREF(pto->dict); - pto->ob_type->tp_free(pto); + Py_Type(pto)->tp_free(pto); } static PyObject * @@ -197,8 +197,7 @@ static PyGetSetDef partial_getsetlist[] = { }; static PyTypeObject partial_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "functools.partial", /* tp_name */ sizeof(partialobject), /* tp_basicsize */ 0, /* tp_itemsize */ diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c index 859644f..fa8dafc 100644 --- a/Modules/_hashopenssl.c +++ b/Modules/_hashopenssl.c @@ -281,8 +281,7 @@ name -- the hash algorithm being used by this object\n\ digest_size -- number of bytes in this hashes output\n"); static PyTypeObject EVPtype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "_hashlib.HASH", /*tp_name*/ sizeof(EVPobject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -464,7 +463,7 @@ init_hashlib(void) * but having some be unsupported. Only init appropriate * constants. */ - EVPtype.ob_type = &PyType_Type; + Py_Type(&EVPtype) = &PyType_Type; if (PyType_Ready(&EVPtype) < 0) return; diff --git a/Modules/_hotshot.c b/Modules/_hotshot.c index 21bd383..4bbb3b5 100644 --- a/Modules/_hotshot.c +++ b/Modules/_hotshot.c @@ -1220,8 +1220,7 @@ PyDoc_STRVAR(profiler_object__doc__, "linetimings: True if line events collect timing information."); static PyTypeObject ProfilerType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "_hotshot.ProfilerType", /* tp_name */ (int) sizeof(ProfilerObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1305,8 +1304,7 @@ static PyGetSetDef logreader_getsets[] = { }; static PyTypeObject LogReaderType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "_hotshot.LogReaderType", /* tp_name */ (int) sizeof(LogReaderObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1613,8 +1611,8 @@ init_hotshot(void) { PyObject *module; - LogReaderType.ob_type = &PyType_Type; - ProfilerType.ob_type = &PyType_Type; + Py_Type(&LogReaderType) = &PyType_Type; + Py_Type(&ProfilerType) = &PyType_Type; module = Py_InitModule("_hotshot", functions); if (module != NULL) { char *s = get_version_string(); diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index d35c894..5b03b56 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -120,7 +120,7 @@ typedef struct { staticforward PyTypeObject PyProfiler_Type; #define PyProfiler_Check(op) PyObject_TypeCheck(op, &PyProfiler_Type) -#define PyProfiler_CheckExact(op) ((op)->ob_type == &PyProfiler_Type) +#define PyProfiler_CheckExact(op) (Py_Type(op) == &PyProfiler_Type) /*** External Timers ***/ @@ -207,7 +207,7 @@ normalizeUserObj(PyObject *obj) PyObject *self = fn->m_self; PyObject *name = PyString_FromString(fn->m_ml->ml_name); if (name != NULL) { - PyObject *mo = _PyType_Lookup(self->ob_type, name); + PyObject *mo = _PyType_Lookup(Py_Type(self), name); Py_XINCREF(mo); Py_DECREF(name); if (mo != NULL) { @@ -744,7 +744,7 @@ profiler_dealloc(ProfilerObject *op) flush_unmatched(op); clearEntries(op); Py_XDECREF(op->externalTimer); - op->ob_type->tp_free(op); + Py_Type(op)->tp_free(op); } static int diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c index 591947e..25adc2e 100644 --- a/Modules/_randommodule.c +++ b/Modules/_randommodule.c @@ -84,7 +84,7 @@ typedef struct { static PyTypeObject Random_Type; -#define RandomObject_Check(v) ((v)->ob_type == &Random_Type) +#define RandomObject_Check(v) (Py_Type(v) == &Random_Type) /* Random methods */ @@ -404,7 +404,7 @@ random_jumpahead(RandomObject *self, PyObject *n) if (!PyInt_Check(n) && !PyLong_Check(n)) { PyErr_Format(PyExc_TypeError, "jumpahead requires an " "integer, not '%s'", - n->ob_type->tp_name); + Py_Type(n)->tp_name); return NULL; } @@ -518,8 +518,7 @@ PyDoc_STRVAR(random_doc, "Random() -> create a random number generator with its own internal state."); static PyTypeObject Random_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "_random.Random", /*tp_name*/ sizeof(RandomObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/Modules/_sqlite/cache.c b/Modules/_sqlite/cache.c index 6094eb3..829c175 100644 --- a/Modules/_sqlite/cache.c +++ b/Modules/_sqlite/cache.c @@ -51,7 +51,7 @@ void pysqlite_node_dealloc(pysqlite_Node* self) Py_DECREF(self->key); Py_DECREF(self->data); - self->ob_type->tp_free((PyObject*)self); + Py_Type(self)->tp_free((PyObject*)self); } int pysqlite_cache_init(pysqlite_Cache* self, PyObject* args, PyObject* kwargs) @@ -109,7 +109,7 @@ void pysqlite_cache_dealloc(pysqlite_Cache* self) } Py_DECREF(self->mapping); - self->ob_type->tp_free((PyObject*)self); + Py_Type(self)->tp_free((PyObject*)self); } PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* args) @@ -274,8 +274,7 @@ static PyMethodDef cache_methods[] = { }; PyTypeObject pysqlite_NodeType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) MODULE_NAME "Node", /* tp_name */ sizeof(pysqlite_Node), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -317,8 +316,7 @@ PyTypeObject pysqlite_NodeType = { }; PyTypeObject pysqlite_CacheType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) MODULE_NAME ".Cache", /* tp_name */ sizeof(pysqlite_Cache), /* tp_basicsize */ 0, /* tp_itemsize */ diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 924d582..add2e6f 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -205,7 +205,7 @@ void pysqlite_connection_dealloc(pysqlite_Connection* self) Py_XDECREF(self->collations); Py_XDECREF(self->statements); - self->ob_type->tp_free((PyObject*)self); + Py_Type(self)->tp_free((PyObject*)self); } PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) @@ -1206,8 +1206,7 @@ static struct PyMemberDef connection_members[] = }; PyTypeObject pysqlite_ConnectionType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) MODULE_NAME ".Connection", /* tp_name */ sizeof(pysqlite_Connection), /* tp_basicsize */ 0, /* tp_itemsize */ diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 4ca1063..2032a25 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -134,7 +134,7 @@ void pysqlite_cursor_dealloc(pysqlite_Cursor* self) Py_XDECREF(self->row_factory); Py_XDECREF(self->next_row); - self->ob_type->tp_free((PyObject*)self); + Py_Type(self)->tp_free((PyObject*)self); } PyObject* _pysqlite_get_converter(PyObject* key) @@ -1020,8 +1020,7 @@ static char cursor_doc[] = PyDoc_STR("SQLite database cursor class."); PyTypeObject pysqlite_CursorType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) MODULE_NAME ".Cursor", /* tp_name */ sizeof(pysqlite_Cursor), /* tp_basicsize */ 0, /* tp_itemsize */ diff --git a/Modules/_sqlite/prepare_protocol.c b/Modules/_sqlite/prepare_protocol.c index a8ca518..c979610 100644 --- a/Modules/_sqlite/prepare_protocol.c +++ b/Modules/_sqlite/prepare_protocol.c @@ -30,12 +30,11 @@ int pysqlite_prepare_protocol_init(pysqlite_PrepareProtocol* self, PyObject* arg void pysqlite_prepare_protocol_dealloc(pysqlite_PrepareProtocol* self) { - self->ob_type->tp_free((PyObject*)self); + Py_Type(self)->tp_free((PyObject*)self); } PyTypeObject pysqlite_PrepareProtocolType= { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) MODULE_NAME ".PrepareProtocol", /* tp_name */ sizeof(pysqlite_PrepareProtocol), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -79,6 +78,6 @@ PyTypeObject pysqlite_PrepareProtocolType= { extern int pysqlite_prepare_protocol_setup_types(void) { pysqlite_PrepareProtocolType.tp_new = PyType_GenericNew; - pysqlite_PrepareProtocolType.ob_type= &PyType_Type; + Py_Type(&pysqlite_PrepareProtocolType)= &PyType_Type; return PyType_Ready(&pysqlite_PrepareProtocolType); } diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c index 7cfcfc3..9ada8a9 100644 --- a/Modules/_sqlite/row.c +++ b/Modules/_sqlite/row.c @@ -30,7 +30,7 @@ void pysqlite_row_dealloc(pysqlite_Row* self) Py_XDECREF(self->data); Py_XDECREF(self->description); - self->ob_type->tp_free((PyObject*)self); + Py_Type(self)->tp_free((PyObject*)self); } int pysqlite_row_init(pysqlite_Row* self, PyObject* args, PyObject* kwargs) @@ -183,8 +183,7 @@ static PyMethodDef pysqlite_row_methods[] = { PyTypeObject pysqlite_RowType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) MODULE_NAME ".Row", /* tp_name */ sizeof(pysqlite_Row), /* tp_basicsize */ 0, /* tp_itemsize */ diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c index 86d2178..20c1aac 100644 --- a/Modules/_sqlite/statement.c +++ b/Modules/_sqlite/statement.c @@ -309,7 +309,7 @@ void pysqlite_statement_dealloc(pysqlite_Statement* self) PyObject_ClearWeakRefs((PyObject*)self); } - self->ob_type->tp_free((PyObject*)self); + Py_Type(self)->tp_free((PyObject*)self); } /* @@ -383,8 +383,7 @@ static int pysqlite_check_remaining_sql(const char* tail) } PyTypeObject pysqlite_StatementType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) MODULE_NAME ".Statement", /* tp_name */ sizeof(pysqlite_Statement), /* tp_basicsize */ 0, /* tp_itemsize */ diff --git a/Modules/_sre.c b/Modules/_sre.c index c1eb71c..7dafaeb 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -1689,7 +1689,7 @@ getstring(PyObject* string, Py_ssize_t* p_length, int* p_charsize) #endif /* get pointer to string buffer */ - buffer = string->ob_type->tp_as_buffer; + buffer = Py_Type(string)->tp_as_buffer; if (!buffer || !buffer->bf_getreadbuffer || !buffer->bf_getsegcount || buffer->bf_getsegcount(string, NULL) != 1) { PyErr_SetString(PyExc_TypeError, "expected string or buffer"); diff --git a/Modules/_ssl.c b/Modules/_ssl.c index f1e1092..d0f7115 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -72,7 +72,7 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args); static int check_socket_and_wait_for_timeout(PySocketSockObject *s, int writing); -#define PySSLObject_Check(v) ((v)->ob_type == &PySSL_Type) +#define PySSLObject_Check(v) (Py_Type(v) == &PySSL_Type) typedef enum { SOCKET_IS_NONBLOCKING, @@ -570,8 +570,7 @@ static PyObject *PySSL_getattr(PySSLObject *self, char *name) } static PyTypeObject PySSL_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "socket.SSL", /*tp_name*/ sizeof(PySSLObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -632,7 +631,7 @@ PySSL_RAND_egd(PyObject *self, PyObject *arg) if (!PyString_Check(arg)) return PyErr_Format(PyExc_TypeError, "RAND_egd() expected string, found %s", - arg->ob_type->tp_name); + Py_Type(arg)->tp_name); bytes = RAND_egd(PyString_AS_STRING(arg)); if (bytes == -1) { PyErr_SetString(PySSLErrorObject, @@ -678,7 +677,7 @@ init_ssl(void) { PyObject *m, *d; - PySSL_Type.ob_type = &PyType_Type; + Py_Type(&PySSL_Type) = &PyType_Type; m = Py_InitModule3("_ssl", PySSL_methods, module_doc); if (m == NULL) 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 @@ 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; diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 84dc1e1..c5a0bc5 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -839,8 +839,7 @@ static void test_structmembers_free(PyObject *ob){ } static PyTypeObject test_structmembersType = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "test_structmembersType", sizeof(test_structmembers), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -890,7 +889,7 @@ init_testcapi(void) if (m == NULL) return; - test_structmembersType.ob_type=&PyType_Type; + Py_Type(&test_structmembersType)=&PyType_Type; Py_INCREF(&test_structmembersType); PyModule_AddObject(m, "test_structmembersType", (PyObject *)&test_structmembersType); diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 22d930b..07570f3 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -262,12 +262,12 @@ typedef struct { Tcl_ObjType *StringType; } TkappObject; -#define Tkapp_Check(v) ((v)->ob_type == &Tkapp_Type) +#define Tkapp_Check(v) (Py_Type(v) == &Tkapp_Type) #define Tkapp_Interp(v) (((TkappObject *) (v))->interp) #define Tkapp_Result(v) Tcl_GetStringResult(Tkapp_Interp(v)) #define DEBUG_REFCNT(v) (printf("DEBUG: id=%p, refcnt=%i\n", \ -(void *) v, ((PyObject *) v)->ob_refcnt)) +(void *) v, Py_Refcnt(v))) @@ -2420,8 +2420,7 @@ Tktt_GetAttr(PyObject *self, char *name) static PyTypeObject Tktt_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "tktimertoken", /*tp_name */ sizeof(TkttObject), /*tp_basicsize */ 0, /*tp_itemsize */ @@ -2765,8 +2764,7 @@ Tkapp_GetAttr(PyObject *self, char *name) static PyTypeObject Tkapp_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "tkapp", /*tp_name */ sizeof(TkappObject), /*tp_basicsize */ 0, /*tp_itemsize */ @@ -3105,7 +3103,7 @@ init_tkinter(void) { PyObject *m, *d; - Tkapp_Type.ob_type = &PyType_Type; + Py_Type(&Tkapp_Type) = &PyType_Type; #ifdef WITH_THREAD tcl_lock = PyThread_allocate_lock(); @@ -3133,10 +3131,10 @@ init_tkinter(void) PyDict_SetItemString(d, "TkappType", (PyObject *)&Tkapp_Type); - Tktt_Type.ob_type = &PyType_Type; + Py_Type(&Tktt_Type) = &PyType_Type; PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type); - PyTclObject_Type.ob_type = &PyType_Type; + Py_Type(&PyTclObject_Type) = &PyType_Type; PyDict_SetItemString(d, "Tcl_Obj", (PyObject *)&PyTclObject_Type); #ifdef TK_AQUA diff --git a/Modules/_typesmodule.c b/Modules/_typesmodule.c index 5a6f2b9..e925664 100644 --- a/Modules/_typesmodule.c +++ b/Modules/_typesmodule.c @@ -33,8 +33,7 @@ static PyGetSetDef helper_getset[] = { }; static PyTypeObject HelperType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "_types.Helper", /* tp_name */ sizeof(Helper), /* tp_basicsize */ 0, /* tp_itemsize */ diff --git a/Modules/_weakref.c b/Modules/_weakref.c index 1712f12..cb7977b 100644 --- a/Modules/_weakref.c +++ b/Modules/_weakref.c @@ -14,7 +14,7 @@ weakref_getweakrefcount(PyObject *self, PyObject *object) { PyObject *result = NULL; - if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) { + if (PyType_SUPPORTS_WEAKREFS(Py_Type(object))) { PyWeakReference **list = GET_WEAKREFS_LISTPTR(object); result = PyInt_FromSsize_t(_PyWeakref_GetWeakrefCount(*list)); @@ -35,7 +35,7 @@ weakref_getweakrefs(PyObject *self, PyObject *object) { PyObject *result = NULL; - if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) { + if (PyType_SUPPORTS_WEAKREFS(Py_Type(object))) { PyWeakReference **list = GET_WEAKREFS_LISTPTR(object); Py_ssize_t count = _PyWeakref_GetWeakrefCount(*list); diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 3ba5cf8..21a5e5b 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -39,7 +39,7 @@ typedef struct arrayobject { static PyTypeObject Arraytype; #define array_Check(op) PyObject_TypeCheck(op, &Arraytype) -#define array_CheckExact(op) ((op)->ob_type == &Arraytype) +#define array_CheckExact(op) (Py_Type(op) == &Arraytype) static int array_resize(arrayobject *self, Py_ssize_t newsize) @@ -53,9 +53,9 @@ array_resize(arrayobject *self, Py_ssize_t newsize) */ if (self->allocated >= newsize && - self->ob_size < newsize + 16 && + Py_Size(self) < newsize + 16 && self->ob_item != NULL) { - self->ob_size = newsize; + Py_Size(self) = newsize; return 0; } @@ -71,7 +71,7 @@ array_resize(arrayobject *self, Py_ssize_t newsize) * memory critical. */ - _new_size = (newsize >> 4) + (self->ob_size < 8 ? 3 : 7) + newsize; + _new_size = (newsize >> 4) + (Py_Size(self) < 8 ? 3 : 7) + newsize; items = self->ob_item; /* XXX The following multiplication and division does not optimize away like it does for lists since the size is not known at compile time */ @@ -84,7 +84,7 @@ array_resize(arrayobject *self, Py_ssize_t newsize) return -1; } self->ob_item = items; - self->ob_size = newsize; + Py_Size(self) = newsize; self->allocated = _new_size; return 0; } @@ -432,7 +432,7 @@ newarrayobject(PyTypeObject *type, Py_ssize_t size, struct arraydescr *descr) if (op == NULL) { return NULL; } - op->ob_size = size; + Py_Size(op) = size; if (size <= 0) { op->ob_item = NULL; } @@ -455,7 +455,7 @@ getarrayitem(PyObject *op, Py_ssize_t i) register arrayobject *ap; assert(array_Check(op)); ap = (arrayobject *)op; - assert(i>=0 && i<ap->ob_size); + assert(i>=0 && i<Py_Size(ap)); return (*ap->ob_descr->getitem)(ap, i); } @@ -463,7 +463,7 @@ static int ins1(arrayobject *self, Py_ssize_t where, PyObject *v) { char *items; - Py_ssize_t n = self->ob_size; + Py_ssize_t n = Py_Size(self); if (v == NULL) { PyErr_BadInternalCall(); return -1; @@ -498,7 +498,7 @@ array_dealloc(arrayobject *op) PyObject_ClearWeakRefs((PyObject *) op); if (op->ob_item != NULL) PyMem_DEL(op->ob_item); - op->ob_type->tp_free((PyObject *)op); + Py_Type(op)->tp_free((PyObject *)op); } static PyObject * @@ -518,7 +518,7 @@ array_richcompare(PyObject *v, PyObject *w, int op) va = (arrayobject *)v; wa = (arrayobject *)w; - if (va->ob_size != wa->ob_size && (op == Py_EQ || op == Py_NE)) { + if (Py_Size(va) != Py_Size(wa) && (op == Py_EQ || op == Py_NE)) { /* Shortcut: if the lengths differ, the arrays differ */ if (op == Py_EQ) res = Py_False; @@ -530,7 +530,7 @@ array_richcompare(PyObject *v, PyObject *w, int op) /* Search for the first index where items are different */ k = 1; - for (i = 0; i < va->ob_size && i < wa->ob_size; i++) { + for (i = 0; i < Py_Size(va) && i < Py_Size(wa); i++) { vi = getarrayitem(v, i); wi = getarrayitem(w, i); if (vi == NULL || wi == NULL) { @@ -549,8 +549,8 @@ array_richcompare(PyObject *v, PyObject *w, int op) if (k) { /* No more items to compare -- compare sizes */ - Py_ssize_t vs = va->ob_size; - Py_ssize_t ws = wa->ob_size; + Py_ssize_t vs = Py_Size(va); + Py_ssize_t ws = Py_Size(wa); int cmp; switch (op) { case Py_LT: cmp = vs < ws; break; @@ -590,13 +590,13 @@ array_richcompare(PyObject *v, PyObject *w, int op) static Py_ssize_t array_length(arrayobject *a) { - return a->ob_size; + return Py_Size(a); } static PyObject * array_item(arrayobject *a, Py_ssize_t i) { - if (i < 0 || i >= a->ob_size) { + if (i < 0 || i >= Py_Size(a)) { PyErr_SetString(PyExc_IndexError, "array index out of range"); return NULL; } @@ -609,14 +609,14 @@ array_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh) arrayobject *np; if (ilow < 0) ilow = 0; - else if (ilow > a->ob_size) - ilow = a->ob_size; + else if (ilow > Py_Size(a)) + ilow = Py_Size(a); if (ihigh < 0) ihigh = 0; if (ihigh < ilow) ihigh = ilow; - else if (ihigh > a->ob_size) - ihigh = a->ob_size; + else if (ihigh > Py_Size(a)) + ihigh = Py_Size(a); np = (arrayobject *) newarrayobject(&Arraytype, ihigh - ilow, a->ob_descr); if (np == NULL) return NULL; @@ -628,7 +628,7 @@ array_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh) static PyObject * array_copy(arrayobject *a, PyObject *unused) { - return array_slice(a, 0, a->ob_size); + return array_slice(a, 0, Py_Size(a)); } PyDoc_STRVAR(copy_doc, @@ -644,7 +644,7 @@ array_concat(arrayobject *a, PyObject *bb) if (!array_Check(bb)) { PyErr_Format(PyExc_TypeError, "can only append array (not \"%.200s\") to array", - bb->ob_type->tp_name); + Py_Type(bb)->tp_name); return NULL; } #define b ((arrayobject *)bb) @@ -652,14 +652,14 @@ array_concat(arrayobject *a, PyObject *bb) PyErr_BadArgument(); return NULL; } - size = a->ob_size + b->ob_size; + size = Py_Size(a) + Py_Size(b); np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr); if (np == NULL) { return NULL; } - memcpy(np->ob_item, a->ob_item, a->ob_size*a->ob_descr->itemsize); - memcpy(np->ob_item + a->ob_size*a->ob_descr->itemsize, - b->ob_item, b->ob_size*b->ob_descr->itemsize); + memcpy(np->ob_item, a->ob_item, Py_Size(a)*a->ob_descr->itemsize); + memcpy(np->ob_item + Py_Size(a)*a->ob_descr->itemsize, + b->ob_item, Py_Size(b)*b->ob_descr->itemsize); return (PyObject *)np; #undef b } @@ -674,12 +674,12 @@ array_repeat(arrayobject *a, Py_ssize_t n) Py_ssize_t nbytes; if (n < 0) n = 0; - size = a->ob_size * n; + size = Py_Size(a) * n; np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr); if (np == NULL) return NULL; p = np->ob_item; - nbytes = a->ob_size * a->ob_descr->itemsize; + nbytes = Py_Size(a) * a->ob_descr->itemsize; for (i = 0; i < n; i++) { memcpy(p, a->ob_item, nbytes); p += nbytes; @@ -697,7 +697,7 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v) if (v == NULL) n = 0; else if (array_Check(v)) { - n = b->ob_size; + n = Py_Size(b); if (a == b) { /* Special case "a[i:j] = a" -- copy b first */ int ret; @@ -716,44 +716,44 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v) else { PyErr_Format(PyExc_TypeError, "can only assign array (not \"%.200s\") to array slice", - v->ob_type->tp_name); + Py_Type(v)->tp_name); return -1; } if (ilow < 0) ilow = 0; - else if (ilow > a->ob_size) - ilow = a->ob_size; + else if (ilow > Py_Size(a)) + ilow = Py_Size(a); if (ihigh < 0) ihigh = 0; if (ihigh < ilow) ihigh = ilow; - else if (ihigh > a->ob_size) - ihigh = a->ob_size; + else if (ihigh > Py_Size(a)) + ihigh = Py_Size(a); item = a->ob_item; d = n - (ihigh-ilow); if (d < 0) { /* Delete -d items */ memmove(item + (ihigh+d)*a->ob_descr->itemsize, item + ihigh*a->ob_descr->itemsize, - (a->ob_size-ihigh)*a->ob_descr->itemsize); - a->ob_size += d; - PyMem_RESIZE(item, char, a->ob_size*a->ob_descr->itemsize); + (Py_Size(a)-ihigh)*a->ob_descr->itemsize); + Py_Size(a) += d; + PyMem_RESIZE(item, char, Py_Size(a)*a->ob_descr->itemsize); /* Can't fail */ a->ob_item = item; - a->allocated = a->ob_size; + a->allocated = Py_Size(a); } else if (d > 0) { /* Insert d items */ PyMem_RESIZE(item, char, - (a->ob_size + d)*a->ob_descr->itemsize); + (Py_Size(a) + d)*a->ob_descr->itemsize); if (item == NULL) { PyErr_NoMemory(); return -1; } memmove(item + (ihigh+d)*a->ob_descr->itemsize, item + ihigh*a->ob_descr->itemsize, - (a->ob_size-ihigh)*a->ob_descr->itemsize); + (Py_Size(a)-ihigh)*a->ob_descr->itemsize); a->ob_item = item; - a->ob_size += d; - a->allocated = a->ob_size; + Py_Size(a) += d; + a->allocated = Py_Size(a); } if (n > 0) memcpy(item + ilow*a->ob_descr->itemsize, b->ob_item, @@ -765,7 +765,7 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v) static int array_ass_item(arrayobject *a, Py_ssize_t i, PyObject *v) { - if (i < 0 || i >= a->ob_size) { + if (i < 0 || i >= Py_Size(a)) { PyErr_SetString(PyExc_IndexError, "array assignment index out of range"); return -1; @@ -792,7 +792,7 @@ array_iter_extend(arrayobject *self, PyObject *bb) return -1; while ((v = PyIter_Next(it)) != NULL) { - if (ins1(self, (int) self->ob_size, v) != 0) { + if (ins1(self, (int) Py_Size(self), v) != 0) { Py_DECREF(v); Py_DECREF(it); return -1; @@ -818,16 +818,16 @@ array_do_extend(arrayobject *self, PyObject *bb) "can only extend with array of same kind"); return -1; } - size = self->ob_size + b->ob_size; + size = Py_Size(self) + Py_Size(b); PyMem_RESIZE(self->ob_item, char, size*self->ob_descr->itemsize); if (self->ob_item == NULL) { PyObject_Del(self); PyErr_NoMemory(); return -1; } - memcpy(self->ob_item + self->ob_size*self->ob_descr->itemsize, - b->ob_item, b->ob_size*b->ob_descr->itemsize); - self->ob_size = size; + memcpy(self->ob_item + Py_Size(self)*self->ob_descr->itemsize, + b->ob_item, Py_Size(b)*b->ob_descr->itemsize); + Py_Size(self) = size; self->allocated = size; return 0; @@ -840,7 +840,7 @@ array_inplace_concat(arrayobject *self, PyObject *bb) if (!array_Check(bb)) { PyErr_Format(PyExc_TypeError, "can only extend array with array (not \"%.200s\")", - bb->ob_type->tp_name); + Py_Type(bb)->tp_name); return NULL; } if (array_do_extend(self, bb) == -1) @@ -855,15 +855,15 @@ array_inplace_repeat(arrayobject *self, Py_ssize_t n) char *items, *p; Py_ssize_t size, i; - if (self->ob_size > 0) { + if (Py_Size(self) > 0) { if (n < 0) n = 0; items = self->ob_item; - size = self->ob_size * self->ob_descr->itemsize; + size = Py_Size(self) * self->ob_descr->itemsize; if (n == 0) { PyMem_FREE(items); self->ob_item = NULL; - self->ob_size = 0; + Py_Size(self) = 0; self->allocated = 0; } else { @@ -876,8 +876,8 @@ array_inplace_repeat(arrayobject *self, Py_ssize_t n) memcpy(p, items, size); } self->ob_item = items; - self->ob_size *= n; - self->allocated = self->ob_size; + Py_Size(self) *= n; + self->allocated = Py_Size(self); } } Py_INCREF(self); @@ -900,7 +900,7 @@ array_count(arrayobject *self, PyObject *v) Py_ssize_t count = 0; Py_ssize_t i; - for (i = 0; i < self->ob_size; i++) { + for (i = 0; i < Py_Size(self); i++) { PyObject *selfi = getarrayitem((PyObject *)self, i); int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); Py_DECREF(selfi); @@ -922,7 +922,7 @@ array_index(arrayobject *self, PyObject *v) { Py_ssize_t i; - for (i = 0; i < self->ob_size; i++) { + for (i = 0; i < Py_Size(self); i++) { PyObject *selfi = getarrayitem((PyObject *)self, i); int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); Py_DECREF(selfi); @@ -947,7 +947,7 @@ array_contains(arrayobject *self, PyObject *v) Py_ssize_t i; int cmp; - for (i = 0, cmp = 0 ; cmp == 0 && i < self->ob_size; i++) { + for (i = 0, cmp = 0 ; cmp == 0 && i < Py_Size(self); i++) { PyObject *selfi = getarrayitem((PyObject *)self, i); cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); Py_DECREF(selfi); @@ -960,7 +960,7 @@ array_remove(arrayobject *self, PyObject *v) { int i; - for (i = 0; i < self->ob_size; i++) { + for (i = 0; i < Py_Size(self); i++) { PyObject *selfi = getarrayitem((PyObject *)self,i); int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); Py_DECREF(selfi); @@ -990,14 +990,14 @@ array_pop(arrayobject *self, PyObject *args) PyObject *v; if (!PyArg_ParseTuple(args, "|n:pop", &i)) return NULL; - if (self->ob_size == 0) { + if (Py_Size(self) == 0) { /* Special-case most common failure cause */ PyErr_SetString(PyExc_IndexError, "pop from empty array"); return NULL; } if (i < 0) - i += self->ob_size; - if (i < 0 || i >= self->ob_size) { + i += Py_Size(self); + if (i < 0 || i >= Py_Size(self)) { PyErr_SetString(PyExc_IndexError, "pop index out of range"); return NULL; } @@ -1053,7 +1053,7 @@ array_buffer_info(arrayobject *self, PyObject *unused) return NULL; PyTuple_SET_ITEM(retval, 0, PyLong_FromVoidPtr(self->ob_item)); - PyTuple_SET_ITEM(retval, 1, PyInt_FromLong((long)(self->ob_size))); + PyTuple_SET_ITEM(retval, 1, PyInt_FromLong((long)(Py_Size(self)))); return retval; } @@ -1070,7 +1070,7 @@ the buffer length in bytes."); static PyObject * array_append(arrayobject *self, PyObject *v) { - return ins(self, (int) self->ob_size, v); + return ins(self, (int) Py_Size(self), v); } PyDoc_STRVAR(append_doc, @@ -1089,14 +1089,14 @@ array_byteswap(arrayobject *self, PyObject *unused) case 1: break; case 2: - for (p = self->ob_item, i = self->ob_size; --i >= 0; p += 2) { + for (p = self->ob_item, i = Py_Size(self); --i >= 0; p += 2) { char p0 = p[0]; p[0] = p[1]; p[1] = p0; } break; case 4: - for (p = self->ob_item, i = self->ob_size; --i >= 0; p += 4) { + for (p = self->ob_item, i = Py_Size(self); --i >= 0; p += 4) { char p0 = p[0]; char p1 = p[1]; p[0] = p[3]; @@ -1106,7 +1106,7 @@ array_byteswap(arrayobject *self, PyObject *unused) } break; case 8: - for (p = self->ob_item, i = self->ob_size; --i >= 0; p += 8) { + for (p = self->ob_item, i = Py_Size(self); --i >= 0; p += 8) { char p0 = p[0]; char p1 = p[1]; char p2 = p[2]; @@ -1147,16 +1147,16 @@ array_reduce(arrayobject *array) dict = Py_None; Py_INCREF(dict); } - if (array->ob_size > 0) { + if (Py_Size(array) > 0) { result = Py_BuildValue("O(cs#)O", - array->ob_type, + Py_Type(array), array->ob_descr->typecode, array->ob_item, - array->ob_size * array->ob_descr->itemsize, + Py_Size(array) * array->ob_descr->itemsize, dict); } else { result = Py_BuildValue("O(c)O", - array->ob_type, + Py_Type(array), array->ob_descr->typecode, dict); } @@ -1175,9 +1175,9 @@ array_reverse(arrayobject *self, PyObject *unused) char tmp[256]; /* 8 is probably enough -- but why skimp */ assert((size_t)itemsize <= sizeof(tmp)); - if (self->ob_size > 1) { + if (Py_Size(self) > 1) { for (p = self->ob_item, - q = self->ob_item + (self->ob_size - 1)*itemsize; + q = self->ob_item + (Py_Size(self) - 1)*itemsize; p < q; p += itemsize, q -= itemsize) { /* memory areas guaranteed disjoint, so memcpy @@ -1218,7 +1218,7 @@ array_fromfile(arrayobject *self, PyObject *args) Py_ssize_t newlength; size_t newbytes; /* Be careful here about overflow */ - if ((newlength = self->ob_size + n) <= 0 || + if ((newlength = Py_Size(self) + n) <= 0 || (newbytes = newlength * itemsize) / itemsize != (size_t)newlength) goto nomem; @@ -1229,15 +1229,15 @@ array_fromfile(arrayobject *self, PyObject *args) return NULL; } self->ob_item = item; - self->ob_size += n; - self->allocated = self->ob_size; - nread = fread(item + (self->ob_size - n) * itemsize, + Py_Size(self) += n; + self->allocated = Py_Size(self); + nread = fread(item + (Py_Size(self) - n) * itemsize, itemsize, n, fp); if (nread < (size_t)n) { - self->ob_size -= (n - nread); - PyMem_RESIZE(item, char, self->ob_size*itemsize); + Py_Size(self) -= (n - nread); + PyMem_RESIZE(item, char, Py_Size(self)*itemsize); self->ob_item = item; - self->allocated = self->ob_size; + self->allocated = Py_Size(self); PyErr_SetString(PyExc_EOFError, "not enough items in file"); return NULL; @@ -1297,23 +1297,23 @@ array_fromlist(arrayobject *self, PyObject *list) if (n > 0) { char *item = self->ob_item; Py_ssize_t i; - PyMem_RESIZE(item, char, (self->ob_size + n) * itemsize); + PyMem_RESIZE(item, char, (Py_Size(self) + n) * itemsize); if (item == NULL) { PyErr_NoMemory(); return NULL; } self->ob_item = item; - self->ob_size += n; - self->allocated = self->ob_size; + Py_Size(self) += n; + self->allocated = Py_Size(self); for (i = 0; i < n; i++) { PyObject *v = PyList_GetItem(list, i); if ((*self->ob_descr->setitem)(self, - self->ob_size - n + i, v) != 0) { - self->ob_size -= n; + Py_Size(self) - n + i, v) != 0) { + Py_Size(self) -= n; PyMem_RESIZE(item, char, - self->ob_size * itemsize); + Py_Size(self) * itemsize); self->ob_item = item; - self->allocated = self->ob_size; + self->allocated = Py_Size(self); return NULL; } } @@ -1331,12 +1331,12 @@ Append items to array from list."); static PyObject * array_tolist(arrayobject *self, PyObject *unused) { - PyObject *list = PyList_New(self->ob_size); + PyObject *list = PyList_New(Py_Size(self)); Py_ssize_t i; if (list == NULL) return NULL; - for (i = 0; i < self->ob_size; i++) { + for (i = 0; i < Py_Size(self); i++) { PyObject *v = getarrayitem((PyObject *)self, i); if (v == NULL) { Py_DECREF(list); @@ -1369,15 +1369,15 @@ array_fromstring(arrayobject *self, PyObject *args) n = n / itemsize; if (n > 0) { char *item = self->ob_item; - PyMem_RESIZE(item, char, (self->ob_size + n) * itemsize); + PyMem_RESIZE(item, char, (Py_Size(self) + n) * itemsize); if (item == NULL) { PyErr_NoMemory(); return NULL; } self->ob_item = item; - self->ob_size += n; - self->allocated = self->ob_size; - memcpy(item + (self->ob_size - n) * itemsize, + Py_Size(self) += n; + self->allocated = Py_Size(self); + memcpy(item + (Py_Size(self) - n) * itemsize, str, itemsize*n); } Py_INCREF(Py_None); @@ -1395,7 +1395,7 @@ static PyObject * array_tostring(arrayobject *self, PyObject *unused) { return PyString_FromStringAndSize(self->ob_item, - self->ob_size * self->ob_descr->itemsize); + Py_Size(self) * self->ob_descr->itemsize); } PyDoc_STRVAR(tostring_doc, @@ -1423,15 +1423,15 @@ array_fromunicode(arrayobject *self, PyObject *args) } if (n > 0) { Py_UNICODE *item = (Py_UNICODE *) self->ob_item; - PyMem_RESIZE(item, Py_UNICODE, self->ob_size + n); + PyMem_RESIZE(item, Py_UNICODE, Py_Size(self) + n); if (item == NULL) { PyErr_NoMemory(); return NULL; } self->ob_item = (char *) item; - self->ob_size += n; - self->allocated = self->ob_size; - memcpy(item + self->ob_size - n, + Py_Size(self) += n; + self->allocated = Py_Size(self); + memcpy(item + Py_Size(self) - n, ustr, n * sizeof(Py_UNICODE)); } @@ -1456,7 +1456,7 @@ array_tounicode(arrayobject *self, PyObject *unused) "tounicode() may only be called on type 'u' arrays"); return NULL; } - return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, self->ob_size); + return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, Py_Size(self)); } PyDoc_STRVAR(tounicode_doc, @@ -1554,7 +1554,7 @@ array_repr(arrayobject *a) PyObject *s, *t, *v = NULL; Py_ssize_t len; - len = a->ob_size; + len = Py_Size(a); typecode = a->ob_descr->typecode; if (len == 0) { PyOS_snprintf(buf, sizeof(buf), "array('%c')", typecode); @@ -1588,7 +1588,7 @@ array_subscr(arrayobject* self, PyObject* item) return NULL; } if (i < 0) - i += self->ob_size; + i += Py_Size(self); return array_item(self, i); } else if (PySlice_Check(item)) { @@ -1597,7 +1597,7 @@ array_subscr(arrayobject* self, PyObject* item) arrayobject* ar; int itemsize = self->ob_descr->itemsize; - if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size, + if (PySlice_GetIndicesEx((PySliceObject*)item, Py_Size(self), &start, &stop, &step, &slicelength) < 0) { return NULL; } @@ -1636,14 +1636,14 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) if (i==-1 && PyErr_Occurred()) return -1; if (i < 0) - i += self->ob_size; + i += Py_Size(self); return array_ass_item(self, i, value); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; int itemsize = self->ob_descr->itemsize; - if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size, + if (PySlice_GetIndicesEx((PySliceObject*)item, Py_Size(self), &start, &stop, &step, &slicelength) < 0) { return -1; } @@ -1671,17 +1671,17 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) self->ob_item + (cur + 1)*itemsize, (step - 1) * itemsize); } - extra = self->ob_size - (cur + 1); + extra = Py_Size(self) - (cur + 1); if (extra > 0) { memmove(self->ob_item + (cur - i)*itemsize, self->ob_item + (cur + 1)*itemsize, extra*itemsize); } - self->ob_size -= slicelength; + Py_Size(self) -= slicelength; self->ob_item = (char *)PyMem_REALLOC(self->ob_item, - itemsize*self->ob_size); - self->allocated = self->ob_size; + itemsize*Py_Size(self)); + self->allocated = Py_Size(self); return 0; } @@ -1693,16 +1693,16 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) if (!array_Check(value)) { PyErr_Format(PyExc_TypeError, "must assign array (not \"%.200s\") to slice", - value->ob_type->tp_name); + Py_Type(value)->tp_name); return -1; } av = (arrayobject*)value; - if (av->ob_size != slicelength) { + if (Py_Size(av) != slicelength) { PyErr_Format(PyExc_ValueError, "attempt to assign array of size %ld to extended slice of size %ld", - /*XXX*/(long)av->ob_size, /*XXX*/(long)slicelength); + /*XXX*/(long)Py_Size(av), /*XXX*/(long)slicelength); return -1; } @@ -1711,7 +1711,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) /* protect against a[::-1] = a */ if (self == av) { - value = array_slice(av, 0, av->ob_size); + value = array_slice(av, 0, Py_Size(av)); av = (arrayobject*)value; if (!av) return -1; @@ -1758,7 +1758,7 @@ array_buffer_getreadbuf(arrayobject *self, Py_ssize_t index, const void **ptr) *ptr = (void *)self->ob_item; if (*ptr == NULL) *ptr = emptybuf; - return self->ob_size*self->ob_descr->itemsize; + return Py_Size(self)*self->ob_descr->itemsize; } static Py_ssize_t @@ -1772,14 +1772,14 @@ array_buffer_getwritebuf(arrayobject *self, Py_ssize_t index, const void **ptr) *ptr = (void *)self->ob_item; if (*ptr == NULL) *ptr = emptybuf; - return self->ob_size*self->ob_descr->itemsize; + return Py_Size(self)*self->ob_descr->itemsize; } static Py_ssize_t array_buffer_getsegcount(arrayobject *self, Py_ssize_t *lenp) { if ( lenp ) - *lenp = self->ob_size*self->ob_descr->itemsize; + *lenp = Py_Size(self)*self->ob_descr->itemsize; return 1; } @@ -1888,9 +1888,9 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; } self->ob_item = item; - self->ob_size = n / sizeof(Py_UNICODE); + Py_Size(self) = n / sizeof(Py_UNICODE); memcpy(item, PyUnicode_AS_DATA(initial), n); - self->allocated = self->ob_size; + self->allocated = Py_Size(self); } #endif } @@ -1978,8 +1978,7 @@ itemsize -- the length in bytes of one array item\n\ static PyObject *array_iter(arrayobject *ao); static PyTypeObject Arraytype = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "array.array", sizeof(arrayobject), 0, @@ -2060,7 +2059,7 @@ static PyObject * arrayiter_next(arrayiterobject *it) { assert(PyArrayIter_Check(it)); - if (it->index < it->ao->ob_size) + if (it->index < Py_Size(it->ao)) return (*it->getitem)(it->ao, it->index++); return NULL; } @@ -2081,8 +2080,7 @@ arrayiter_traverse(arrayiterobject *it, visitproc visit, void *arg) } static PyTypeObject PyArrayIter_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "arrayiterator", /* tp_name */ sizeof(arrayiterobject), /* tp_basicsize */ 0, /* tp_itemsize */ diff --git a/Modules/bz2module.c b/Modules/bz2module.c index 9d92cf6..053461f 100644 --- a/Modules/bz2module.c +++ b/Modules/bz2module.c @@ -41,7 +41,7 @@ typedef fpos_t Py_off_t; #define MODE_READ_EOF 2 #define MODE_WRITE 3 -#define BZ2FileObject_Check(v) ((v)->ob_type == &BZ2File_Type) +#define BZ2FileObject_Check(v) (Py_Type(v) == &BZ2File_Type) #ifdef BZ_CONFIG_ERROR @@ -1418,7 +1418,7 @@ BZ2File_dealloc(BZ2FileObject *self) } Util_DropReadAhead(self); Py_XDECREF(self->file); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } /* This is a hacked version of Python's fileobject.c:file_getiter(). */ @@ -1480,8 +1480,7 @@ newlines are available only when reading.\n\ ; static PyTypeObject BZ2File_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "bz2.BZ2File", /*tp_name*/ sizeof(BZ2FileObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -1735,7 +1734,7 @@ BZ2Comp_dealloc(BZ2CompObject *self) PyThread_free_lock(self->lock); #endif BZ2_bzCompressEnd(&self->bzs); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } @@ -1752,8 +1751,7 @@ must be a number between 1 and 9.\n\ "); static PyTypeObject BZ2Comp_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "bz2.BZ2Compressor", /*tp_name*/ sizeof(BZ2CompObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -1958,7 +1956,7 @@ BZ2Decomp_dealloc(BZ2DecompObject *self) #endif Py_XDECREF(self->unused_data); BZ2_bzDecompressEnd(&self->bzs); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } @@ -1974,8 +1972,7 @@ decompress() function instead.\n\ "); static PyTypeObject BZ2Decomp_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "bz2.BZ2Decompressor", /*tp_name*/ sizeof(BZ2DecompObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -2209,9 +2206,9 @@ initbz2(void) { PyObject *m; - BZ2File_Type.ob_type = &PyType_Type; - BZ2Comp_Type.ob_type = &PyType_Type; - BZ2Decomp_Type.ob_type = &PyType_Type; + Py_Type(&BZ2File_Type) = &PyType_Type; + Py_Type(&BZ2Comp_Type) = &PyType_Type; + Py_Type(&BZ2Decomp_Type) = &PyType_Type; m = Py_InitModule3("bz2", bz2_methods, bz2__doc__); if (m == NULL) diff --git a/Modules/cPickle.c b/Modules/cPickle.c index dd9887b..fbf6a12 100644 --- a/Modules/cPickle.c +++ b/Modules/cPickle.c @@ -151,12 +151,12 @@ Pdata_dealloc(Pdata *self) } static PyTypeObject PdataType = { - PyObject_HEAD_INIT(NULL) 0, "cPickle.Pdata", sizeof(Pdata), 0, + PyVarObject_HEAD_INIT(NULL, 0) "cPickle.Pdata", sizeof(Pdata), 0, (destructor)Pdata_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0L,0L,0L,0L, "" }; -#define Pdata_Check(O) ((O)->ob_type == &PdataType) +#define Pdata_Check(O) (Py_Type(O) == &PdataType) static PyObject * Pdata_New(void) @@ -316,7 +316,7 @@ Pdata_popList(Pdata *self, int start) } #define FREE_ARG_TUP(self) { \ - if (self->arg->ob_refcnt > 1) { \ + if (Py_Refcnt(self->arg) > 1) { \ Py_DECREF(self->arg); \ self->arg=NULL; \ } \ @@ -752,7 +752,7 @@ get(Picklerobject *self, PyObject *id) static int put(Picklerobject *self, PyObject *ob) { - if (ob->ob_refcnt < 2 || self->fast) + if (Py_Refcnt(ob) < 2 || self->fast) return 0; return put2(self, ob); @@ -916,7 +916,7 @@ fast_save_enter(Picklerobject *self, PyObject *obj) PyErr_Format(PyExc_ValueError, "fast mode: can't pickle cyclic objects " "including object type %s at %p", - obj->ob_type->tp_name, obj); + Py_Type(obj)->tp_name, obj); self->fast_container = -1; return 0; } @@ -2320,7 +2320,7 @@ save(Picklerobject *self, PyObject *args, int pers_save) goto finally; } - type = args->ob_type; + type = Py_Type(args); switch (type->tp_name[0]) { case 'b': @@ -2372,7 +2372,7 @@ save(Picklerobject *self, PyObject *args, int pers_save) #endif } - if (args->ob_refcnt > 1) { + if (Py_Refcnt(args) > 1) { if (!( py_ob_id = PyLong_FromVoidPtr(args))) goto finally; @@ -2913,7 +2913,7 @@ Pickler_dealloc(Picklerobject *self) Py_XDECREF(self->inst_pers_func); Py_XDECREF(self->dispatch_table); PyMem_Free(self->write_buf); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } static int @@ -3037,8 +3037,7 @@ PyDoc_STRVAR(Picklertype__doc__, "Objects that know how to pickle objects\n"); static PyTypeObject Picklertype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "cPickle.Pickler", /*tp_name*/ sizeof(Picklerobject), /*tp_basicsize*/ 0, @@ -5254,7 +5253,7 @@ Unpickler_dealloc(Unpicklerobject *self) free(self->buf); } - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } static int @@ -5483,8 +5482,7 @@ PyDoc_STRVAR(Unpicklertype__doc__, "Objects that know how to unpickle"); static PyTypeObject Unpicklertype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "cPickle.Unpickler", /*tp_name*/ sizeof(Unpicklerobject), /*tp_basicsize*/ 0, @@ -5708,9 +5706,9 @@ initcPickle(void) PyObject *format_version; PyObject *compatible_formats; - Picklertype.ob_type = &PyType_Type; - Unpicklertype.ob_type = &PyType_Type; - PdataType.ob_type = &PyType_Type; + Py_Type(&Picklertype) = &PyType_Type; + Py_Type(&Unpicklertype) = &PyType_Type; + Py_Type(&PdataType) = &PyType_Type; /* Initialize some pieces. We need to do this before module creation, * so we're forced to use a temporary dictionary. :( diff --git a/Modules/cStringIO.c b/Modules/cStringIO.c index 2085696..5834e20 100644 --- a/Modules/cStringIO.c +++ b/Modules/cStringIO.c @@ -514,8 +514,7 @@ O_dealloc(Oobject *self) { PyDoc_STRVAR(Otype__doc__, "Simple type for output to strings."); static PyTypeObject Otype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "cStringIO.StringO", /*tp_name*/ sizeof(Oobject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -635,8 +634,7 @@ PyDoc_STRVAR(Itype__doc__, "Simple type for treating strings as input file streams"); static PyTypeObject Itype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "cStringIO.StringI", /*tp_name*/ sizeof(Iobject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -746,8 +744,8 @@ initcStringIO(void) { d = PyModule_GetDict(m); /* Export C API */ - Itype.ob_type=&PyType_Type; - Otype.ob_type=&PyType_Type; + Py_Type(&Itype)=&PyType_Type; + Py_Type(&Otype)=&PyType_Type; if (PyType_Ready(&Otype) < 0) return; if (PyType_Ready(&Itype) < 0) return; PyDict_SetItemString(d,"cStringIO_CAPI", diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index 9fb9570..cde8822 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -670,8 +670,7 @@ multibytecodec_dealloc(MultibyteCodecObject *self) } static PyTypeObject MultibyteCodec_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "MultibyteCodec", /* tp_name */ sizeof(MultibyteCodecObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -946,12 +945,11 @@ mbiencoder_dealloc(MultibyteIncrementalEncoderObject *self) { PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); - self->ob_type->tp_free(self); + Py_Type(self)->tp_free(self); } static PyTypeObject MultibyteIncrementalEncoder_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "MultibyteIncrementalEncoder", /* tp_name */ sizeof(MultibyteIncrementalEncoderObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1147,12 +1145,11 @@ mbidecoder_dealloc(MultibyteIncrementalDecoderObject *self) { PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); - self->ob_type->tp_free(self); + Py_Type(self)->tp_free(self); } static PyTypeObject MultibyteIncrementalDecoder_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "MultibyteIncrementalDecoder", /* tp_name */ sizeof(MultibyteIncrementalDecoderObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1464,12 +1461,11 @@ mbstreamreader_dealloc(MultibyteStreamReaderObject *self) PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); Py_DECREF(self->stream); - self->ob_type->tp_free(self); + Py_Type(self)->tp_free(self); } static PyTypeObject MultibyteStreamReader_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "MultibyteStreamReader", /* tp_name */ sizeof(MultibyteStreamReaderObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1667,7 +1663,7 @@ mbstreamwriter_dealloc(MultibyteStreamWriterObject *self) PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); Py_DECREF(self->stream); - self->ob_type->tp_free(self); + Py_Type(self)->tp_free(self); } static struct PyMethodDef mbstreamwriter_methods[] = { @@ -1688,8 +1684,7 @@ static PyMemberDef mbstreamwriter_members[] = { }; static PyTypeObject MultibyteStreamWriter_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "MultibyteStreamWriter", /* tp_name */ sizeof(MultibyteStreamWriterObject), /* tp_basicsize */ 0, /* tp_itemsize */ diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c index 026319a..4113e84 100644 --- a/Modules/datetimemodule.c +++ b/Modules/datetimemodule.c @@ -764,7 +764,7 @@ check_tzinfo_subclass(PyObject *p) PyErr_Format(PyExc_TypeError, "tzinfo argument must be None or of a tzinfo subclass, " "not type '%s'", - p->ob_type->tp_name); + Py_Type(p)->tp_name); return -1; } @@ -855,7 +855,7 @@ call_utc_tzinfo_method(PyObject *tzinfo, char *name, PyObject *tzinfoarg, PyErr_Format(PyExc_TypeError, "tzinfo.%s() must return None or " "timedelta, not '%s'", - name, u->ob_type->tp_name); + name, Py_Type(u)->tp_name); } Py_DECREF(u); @@ -948,7 +948,7 @@ call_tzname(PyObject *tzinfo, PyObject *tzinfoarg) if (result != NULL && result != Py_None && ! PyString_Check(result)) { PyErr_Format(PyExc_TypeError, "tzinfo.tzname() must " "return None or a string, not '%s'", - result->ob_type->tp_name); + Py_Type(result)->tp_name); Py_DECREF(result); result = NULL; } @@ -1421,7 +1421,7 @@ cmperror(PyObject *a, PyObject *b) { PyErr_Format(PyExc_TypeError, "can't compare %s to %s", - a->ob_type->tp_name, b->ob_type->tp_name); + Py_Type(a)->tp_name, Py_Type(b)->tp_name); return NULL; } @@ -1876,7 +1876,7 @@ accum(const char* tag, PyObject *sofar, PyObject *num, PyObject *factor, PyErr_Format(PyExc_TypeError, "unsupported type for timedelta %s component: %s", - tag, num->ob_type->tp_name); + tag, Py_Type(num)->tp_name); return NULL; } @@ -1980,18 +1980,18 @@ delta_repr(PyDateTime_Delta *self) { if (GET_TD_MICROSECONDS(self) != 0) return PyString_FromFormat("%s(%d, %d, %d)", - self->ob_type->tp_name, + Py_Type(self)->tp_name, GET_TD_DAYS(self), GET_TD_SECONDS(self), GET_TD_MICROSECONDS(self)); if (GET_TD_SECONDS(self) != 0) return PyString_FromFormat("%s(%d, %d)", - self->ob_type->tp_name, + Py_Type(self)->tp_name, GET_TD_DAYS(self), GET_TD_SECONDS(self)); return PyString_FromFormat("%s(%d)", - self->ob_type->tp_name, + Py_Type(self)->tp_name, GET_TD_DAYS(self)); } @@ -2055,7 +2055,7 @@ delta_getstate(PyDateTime_Delta *self) static PyObject * delta_reduce(PyDateTime_Delta* self) { - return Py_BuildValue("ON", self->ob_type, delta_getstate(self)); + return Py_BuildValue("ON", Py_Type(self), delta_getstate(self)); } #define OFFSET(field) offsetof(PyDateTime_Delta, field) @@ -2125,8 +2125,7 @@ static PyNumberMethods delta_as_number = { }; static PyTypeObject PyDateTime_DeltaType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "datetime.timedelta", /* tp_name */ sizeof(PyDateTime_Delta), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -2415,7 +2414,7 @@ date_repr(PyDateTime_Date *self) char buffer[1028]; const char *type_name; - type_name = self->ob_type->tp_name; + type_name = Py_Type(self)->tp_name; PyOS_snprintf(buffer, sizeof(buffer), "%s(%d, %d, %d)", type_name, GET_YEAR(self), GET_MONTH(self), GET_DAY(self)); @@ -2555,7 +2554,7 @@ date_replace(PyDateTime_Date *self, PyObject *args, PyObject *kw) tuple = Py_BuildValue("iii", year, month, day); if (tuple == NULL) return NULL; - clone = date_new(self->ob_type, tuple, NULL); + clone = date_new(Py_Type(self), tuple, NULL); Py_DECREF(tuple); return clone; } @@ -2605,7 +2604,7 @@ date_getstate(PyDateTime_Date *self) static PyObject * date_reduce(PyDateTime_Date *self, PyObject *arg) { - return Py_BuildValue("(ON)", self->ob_type, date_getstate(self)); + return Py_BuildValue("(ON)", Py_Type(self), date_getstate(self)); } static PyMethodDef date_methods[] = { @@ -2683,8 +2682,7 @@ static PyNumberMethods date_as_number = { }; static PyTypeObject PyDateTime_DateType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "datetime.date", /* tp_name */ sizeof(PyDateTime_Date), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -2908,10 +2906,10 @@ tzinfo_reduce(PyObject *self) if (state == Py_None) { Py_DECREF(state); - return Py_BuildValue("(ON)", self->ob_type, args); + return Py_BuildValue("(ON)", Py_Type(self), args); } else - return Py_BuildValue("(ONN)", self->ob_type, args, state); + return Py_BuildValue("(ONN)", Py_Type(self), args, state); } static PyMethodDef tzinfo_methods[] = { @@ -3106,7 +3104,7 @@ time_dealloc(PyDateTime_Time *self) if (HASTZINFO(self)) { Py_XDECREF(self->tzinfo); } - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } /* @@ -3140,7 +3138,7 @@ static PyObject * time_repr(PyDateTime_Time *self) { char buffer[100]; - const char *type_name = self->ob_type->tp_name; + const char *type_name = Py_Type(self)->tp_name; int h = TIME_GET_HOUR(self); int m = TIME_GET_MINUTE(self); int s = TIME_GET_SECOND(self); @@ -3354,7 +3352,7 @@ time_replace(PyDateTime_Time *self, PyObject *args, PyObject *kw) tuple = Py_BuildValue("iiiiO", hh, mm, ss, us, tzinfo); if (tuple == NULL) return NULL; - clone = time_new(self->ob_type, tuple, NULL); + clone = time_new(Py_Type(self), tuple, NULL); Py_DECREF(tuple); return clone; } @@ -3408,7 +3406,7 @@ time_getstate(PyDateTime_Time *self) static PyObject * time_reduce(PyDateTime_Time *self, PyObject *arg) { - return Py_BuildValue("(ON)", self->ob_type, time_getstate(self)); + return Py_BuildValue("(ON)", Py_Type(self), time_getstate(self)); } static PyMethodDef time_methods[] = { @@ -3902,7 +3900,7 @@ datetime_dealloc(PyDateTime_DateTime *self) if (HASTZINFO(self)) { Py_XDECREF(self->tzinfo); } - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } /* @@ -4051,7 +4049,7 @@ static PyObject * datetime_repr(PyDateTime_DateTime *self) { char buffer[1000]; - const char *type_name = self->ob_type->tp_name; + const char *type_name = Py_Type(self)->tp_name; PyObject *baserepr; if (DATE_GET_MICROSECOND(self)) { @@ -4272,7 +4270,7 @@ datetime_replace(PyDateTime_DateTime *self, PyObject *args, PyObject *kw) tuple = Py_BuildValue("iiiiiiiO", y, m, d, hh, mm, ss, us, tzinfo); if (tuple == NULL) return NULL; - clone = datetime_new(self->ob_type, tuple, NULL); + clone = datetime_new(Py_Type(self), tuple, NULL); Py_DECREF(tuple); return clone; } @@ -4460,7 +4458,7 @@ datetime_getstate(PyDateTime_DateTime *self) static PyObject * datetime_reduce(PyDateTime_DateTime *self, PyObject *arg) { - return Py_BuildValue("(ON)", self->ob_type, datetime_getstate(self)); + return Py_BuildValue("(ON)", Py_Type(self), datetime_getstate(self)); } static PyMethodDef datetime_methods[] = { diff --git a/Modules/dbmmodule.c b/Modules/dbmmodule.c index fa1fde2..ae5eae6 100644 --- a/Modules/dbmmodule.c +++ b/Modules/dbmmodule.c @@ -36,7 +36,7 @@ typedef struct { static PyTypeObject Dbmtype; -#define is_dbmobject(v) ((v)->ob_type == &Dbmtype) +#define is_dbmobject(v) (Py_Type(v) == &Dbmtype) #define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \ { PyErr_SetString(DbmError, "DBM object has already been closed"); \ return NULL; } @@ -302,8 +302,7 @@ dbm_getattr(dbmobject *dp, char *name) } static PyTypeObject Dbmtype = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "dbm.dbm", sizeof(dbmobject), 0, diff --git a/Modules/dlmodule.c b/Modules/dlmodule.c index 5622ed9..63e25c7 100644 --- a/Modules/dlmodule.c +++ b/Modules/dlmodule.c @@ -62,7 +62,7 @@ dl_sym(dlobject *xp, PyObject *args) name = PyString_AS_STRING(args); } else { PyErr_Format(PyExc_TypeError, "expected string, found %.200s", - args->ob_type->tp_name); + Py_Type(args)->tp_name); return NULL; } func = dlsym(xp->dl_handle, name); @@ -141,8 +141,7 @@ dl_getattr(dlobject *xp, char *name) static PyTypeObject Dltype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "dl.dl", /*tp_name*/ sizeof(dlobject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -237,7 +236,7 @@ initdl(void) PyObject *m, *d, *x; /* Initialize object type */ - Dltype.ob_type = &PyType_Type; + Py_Type(&Dltype) = &PyType_Type; /* Create the module and add the functions */ m = Py_InitModule("dl", dl_methods); diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 6c5011c..b6a871b 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -239,7 +239,7 @@ update_refs(PyGC_Head *containers) PyGC_Head *gc = containers->gc.gc_next; for (; gc != containers; gc = gc->gc.gc_next) { assert(gc->gc.gc_refs == GC_REACHABLE); - gc->gc.gc_refs = FROM_GC(gc)->ob_refcnt; + gc->gc.gc_refs = Py_Refcnt(FROM_GC(gc)); /* Python's cyclic gc should never see an incoming refcount * of 0: if something decref'ed to 0, it should have been * deallocated immediately at that time. @@ -291,7 +291,7 @@ subtract_refs(PyGC_Head *containers) traverseproc traverse; PyGC_Head *gc = containers->gc.gc_next; for (; gc != containers; gc=gc->gc.gc_next) { - traverse = FROM_GC(gc)->ob_type->tp_traverse; + traverse = Py_Type(FROM_GC(gc))->tp_traverse; (void) traverse(FROM_GC(gc), (visitproc)visit_decref, NULL); @@ -376,7 +376,7 @@ move_unreachable(PyGC_Head *young, PyGC_Head *unreachable) * the next object to visit. */ PyObject *op = FROM_GC(gc); - traverseproc traverse = op->ob_type->tp_traverse; + traverseproc traverse = Py_Type(op)->tp_traverse; assert(gc->gc.gc_refs > 0); gc->gc.gc_refs = GC_REACHABLE; (void) traverse(op, @@ -472,7 +472,7 @@ move_finalizer_reachable(PyGC_Head *finalizers) PyGC_Head *gc = finalizers->gc.gc_next; for (; gc != finalizers; gc = gc->gc.gc_next) { /* Note that the finalizers list may grow during this. */ - traverse = FROM_GC(gc)->ob_type->tp_traverse; + traverse = Py_Type(FROM_GC(gc))->tp_traverse; (void) traverse(FROM_GC(gc), (visitproc)visit_move, (void *)finalizers); @@ -517,7 +517,7 @@ handle_weakrefs(PyGC_Head *unreachable, PyGC_Head *old) assert(IS_TENTATIVELY_UNREACHABLE(op)); next = gc->gc.gc_next; - if (! PyType_SUPPORTS_WEAKREFS(op->ob_type)) + if (! PyType_SUPPORTS_WEAKREFS(Py_Type(op))) continue; /* It supports weakrefs. Does it have any? */ @@ -654,7 +654,7 @@ debug_cycle(char *msg, PyObject *op) } else if (debug & DEBUG_OBJECTS) { PySys_WriteStderr("gc: %.100s <%.100s %p>\n", - msg, op->ob_type->tp_name, op); + msg, Py_Type(op)->tp_name, op); } } @@ -708,7 +708,7 @@ delete_garbage(PyGC_Head *collectable, PyGC_Head *old) PyList_Append(garbage, op); } else { - if ((clear = op->ob_type->tp_clear) != NULL) { + if ((clear = Py_Type(op)->tp_clear) != NULL) { Py_INCREF(op); clear(op); Py_DECREF(op); @@ -1079,7 +1079,7 @@ gc_referrers_for(PyObject *objs, PyGC_Head *list, PyObject *resultlist) traverseproc traverse; for (gc = list->gc.gc_next; gc != list; gc = gc->gc.gc_next) { obj = FROM_GC(gc); - traverse = obj->ob_type->tp_traverse; + traverse = Py_Type(obj)->tp_traverse; if (obj == objs || obj == resultlist) continue; if (traverse(obj, (visitproc)referrersvisit, objs)) { @@ -1136,7 +1136,7 @@ gc_get_referents(PyObject *self, PyObject *args) if (! PyObject_IS_GC(obj)) continue; - traverse = obj->ob_type->tp_traverse; + traverse = Py_Type(obj)->tp_traverse; if (! traverse) continue; if (traverse(obj, (visitproc)referentsvisit, result)) { @@ -1359,13 +1359,13 @@ _PyObject_GC_NewVar(PyTypeObject *tp, Py_ssize_t nitems) PyVarObject * _PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems) { - const size_t basicsize = _PyObject_VAR_SIZE(op->ob_type, nitems); + const size_t basicsize = _PyObject_VAR_SIZE(Py_Type(op), nitems); PyGC_Head *g = AS_GC(op); g = (PyGC_Head *)PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize); if (g == NULL) return (PyVarObject *)PyErr_NoMemory(); op = (PyVarObject *) FROM_GC(g); - op->ob_size = nitems; + Py_Size(op) = nitems; return op; } diff --git a/Modules/gdbmmodule.c b/Modules/gdbmmodule.c index cfc6abc..a522059 100644 --- a/Modules/gdbmmodule.c +++ b/Modules/gdbmmodule.c @@ -36,7 +36,7 @@ typedef struct { static PyTypeObject Dbmtype; -#define is_dbmobject(v) ((v)->ob_type == &Dbmtype) +#define is_dbmobject(v) (Py_Type(v) == &Dbmtype) #define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \ { PyErr_SetString(DbmError, "GDBM object has already been closed"); \ return NULL; } @@ -370,8 +370,7 @@ dbm_getattr(dbmobject *dp, char *name) } static PyTypeObject Dbmtype = { - PyObject_HEAD_INIT(0) - 0, + PyVarObject_HEAD_INIT(0, 0) "gdbm.gdbm", sizeof(dbmobject), 0, diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 33172b6..35b77e7 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -59,7 +59,7 @@ groupby_dealloc(groupbyobject *gbo) Py_XDECREF(gbo->tgtkey); Py_XDECREF(gbo->currkey); Py_XDECREF(gbo->currvalue); - gbo->ob_type->tp_free(gbo); + Py_Type(gbo)->tp_free(gbo); } static int @@ -139,8 +139,7 @@ PyDoc_STRVAR(groupby_doc, (key, sub-iterator) grouped by each value of key(value).\n"); static PyTypeObject groupby_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools.groupby", /* tp_name */ sizeof(groupbyobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -261,8 +260,7 @@ _grouper_next(_grouperobject *igo) } static PyTypeObject _grouper_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools._grouper", /* tp_name */ sizeof(_grouperobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -415,8 +413,7 @@ teedataobject_dealloc(teedataobject *tdo) PyDoc_STRVAR(teedataobject_doc, "Data container common to multiple tee objects."); static PyTypeObject teedataobject_type = { - PyObject_HEAD_INIT(0) /* Must fill in type value later */ - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) /* Must fill in type value later */ "itertools.tee_dataobject", /* tp_name */ sizeof(teedataobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -572,8 +569,7 @@ static PyMethodDef tee_methods[] = { }; static PyTypeObject tee_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools.tee", /* tp_name */ sizeof(teeobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -718,7 +714,7 @@ cycle_dealloc(cycleobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->saved); Py_XDECREF(lz->it); - lz->ob_type->tp_free(lz); + Py_Type(lz)->tp_free(lz); } static int @@ -768,8 +764,7 @@ Return elements from the iterable until it is exhausted.\n\ Then repeat the sequence indefinitely."); static PyTypeObject cycle_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools.cycle", /* tp_name */ sizeof(cycleobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -862,7 +857,7 @@ dropwhile_dealloc(dropwhileobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->func); Py_XDECREF(lz->it); - lz->ob_type->tp_free(lz); + Py_Type(lz)->tp_free(lz); } static int @@ -882,7 +877,7 @@ dropwhile_next(dropwhileobject *lz) PyObject *(*iternext)(PyObject *); assert(PyIter_Check(it)); - iternext = *it->ob_type->tp_iternext; + iternext = *Py_Type(it)->tp_iternext; for (;;) { item = iternext(it); if (item == NULL) @@ -912,8 +907,7 @@ Drop items from the iterable while predicate(item) is true.\n\ Afterwards, return every element until the iterable is exhausted."); static PyTypeObject dropwhile_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools.dropwhile", /* tp_name */ sizeof(dropwhileobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1006,7 +1000,7 @@ takewhile_dealloc(takewhileobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->func); Py_XDECREF(lz->it); - lz->ob_type->tp_free(lz); + Py_Type(lz)->tp_free(lz); } static int @@ -1028,7 +1022,7 @@ takewhile_next(takewhileobject *lz) return NULL; assert(PyIter_Check(it)); - item = (*it->ob_type->tp_iternext)(it); + item = (*Py_Type(it)->tp_iternext)(it); if (item == NULL) return NULL; @@ -1053,8 +1047,7 @@ Return successive entries from an iterable as long as the \n\ predicate evaluates to true for each entry."); static PyTypeObject takewhile_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools.takewhile", /* tp_name */ sizeof(takewhileobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1197,7 +1190,7 @@ islice_dealloc(isliceobject *lz) { PyObject_GC_UnTrack(lz); Py_XDECREF(lz->it); - lz->ob_type->tp_free(lz); + Py_Type(lz)->tp_free(lz); } static int @@ -1216,7 +1209,7 @@ islice_next(isliceobject *lz) PyObject *(*iternext)(PyObject *); assert(PyIter_Check(it)); - iternext = *it->ob_type->tp_iternext; + iternext = *Py_Type(it)->tp_iternext; while (lz->cnt < lz->next) { item = iternext(it); if (item == NULL) @@ -1249,8 +1242,7 @@ skipped between successive calls. Works like a slice() on a list\n\ but returns an iterator."); static PyTypeObject islice_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools.islice", /* tp_name */ sizeof(isliceobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1341,7 +1333,7 @@ starmap_dealloc(starmapobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->func); Py_XDECREF(lz->it); - lz->ob_type->tp_free(lz); + Py_Type(lz)->tp_free(lz); } static int @@ -1360,7 +1352,7 @@ starmap_next(starmapobject *lz) PyObject *it = lz->it; assert(PyIter_Check(it)); - args = (*it->ob_type->tp_iternext)(it); + args = (*Py_Type(it)->tp_iternext)(it); if (args == NULL) return NULL; if (!PyTuple_CheckExact(args)) { @@ -1381,8 +1373,7 @@ Return an iterator whose values are returned from the function evaluated\n\ with a argument tuple taken from the given sequence."); static PyTypeObject starmap_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools.starmap", /* tp_name */ sizeof(starmapobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1487,7 +1478,7 @@ imap_dealloc(imapobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->iters); Py_XDECREF(lz->func); - lz->ob_type->tp_free(lz); + Py_Type(lz)->tp_free(lz); } static int @@ -1561,8 +1552,7 @@ iterable is exhausted instead of filling in None for shorter\n\ iterables."); static PyTypeObject imap_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools.imap", /* tp_name */ sizeof(imapobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1666,7 +1656,7 @@ chain_dealloc(chainobject *lz) { PyObject_GC_UnTrack(lz); Py_XDECREF(lz->ittuple); - lz->ob_type->tp_free(lz); + Py_Type(lz)->tp_free(lz); } static int @@ -1706,8 +1696,7 @@ first iterable until it is exhausted, then elements from the next\n\ iterable, until all of the iterables are exhausted."); static PyTypeObject chain_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools.chain", /* tp_name */ sizeof(chainobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1798,7 +1787,7 @@ ifilter_dealloc(ifilterobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->func); Py_XDECREF(lz->it); - lz->ob_type->tp_free(lz); + Py_Type(lz)->tp_free(lz); } static int @@ -1818,7 +1807,7 @@ ifilter_next(ifilterobject *lz) PyObject *(*iternext)(PyObject *); assert(PyIter_Check(it)); - iternext = *it->ob_type->tp_iternext; + iternext = *Py_Type(it)->tp_iternext; for (;;) { item = iternext(it); if (item == NULL) @@ -1850,8 +1839,7 @@ Return those items of sequence for which function(item) is true.\n\ If function is None, return the items that are true."); static PyTypeObject ifilter_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools.ifilter", /* tp_name */ sizeof(ifilterobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1943,7 +1931,7 @@ ifilterfalse_dealloc(ifilterfalseobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->func); Py_XDECREF(lz->it); - lz->ob_type->tp_free(lz); + Py_Type(lz)->tp_free(lz); } static int @@ -1963,7 +1951,7 @@ ifilterfalse_next(ifilterfalseobject *lz) PyObject *(*iternext)(PyObject *); assert(PyIter_Check(it)); - iternext = *it->ob_type->tp_iternext; + iternext = *Py_Type(it)->tp_iternext; for (;;) { item = iternext(it); if (item == NULL) @@ -1995,8 +1983,7 @@ Return those items of sequence for which function(item) is false.\n\ If function is None, return the items that are false."); static PyTypeObject ifilterfalse_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools.ifilterfalse", /* tp_name */ sizeof(ifilterfalseobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -2094,8 +2081,7 @@ Return a count object whose .next() method returns consecutive\n\ integers starting from zero or, if specified, from firstval."); static PyTypeObject count_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools.count", /* tp_name */ sizeof(countobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -2214,7 +2200,7 @@ izip_dealloc(izipobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->ittuple); Py_XDECREF(lz->result); - lz->ob_type->tp_free(lz); + Py_Type(lz)->tp_free(lz); } static int @@ -2237,12 +2223,12 @@ izip_next(izipobject *lz) if (tuplesize == 0) return NULL; - if (result->ob_refcnt == 1) { + if (Py_Refcnt(result) == 1) { Py_INCREF(result); for (i=0 ; i < tuplesize ; i++) { it = PyTuple_GET_ITEM(lz->ittuple, i); assert(PyIter_Check(it)); - item = (*it->ob_type->tp_iternext)(it); + item = (*Py_Type(it)->tp_iternext)(it); if (item == NULL) { Py_DECREF(result); return NULL; @@ -2258,7 +2244,7 @@ izip_next(izipobject *lz) for (i=0 ; i < tuplesize ; i++) { it = PyTuple_GET_ITEM(lz->ittuple, i); assert(PyIter_Check(it)); - item = (*it->ob_type->tp_iternext)(it); + item = (*Py_Type(it)->tp_iternext)(it); if (item == NULL) { Py_DECREF(result); return NULL; @@ -2280,8 +2266,7 @@ function but consumes less memory by returning an iterator instead of\n\ a list."); static PyTypeObject izip_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools.izip", /* tp_name */ sizeof(izipobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -2365,7 +2350,7 @@ repeat_dealloc(repeatobject *ro) { PyObject_GC_UnTrack(ro); Py_XDECREF(ro->element); - ro->ob_type->tp_free(ro); + Py_Type(ro)->tp_free(ro); } static int @@ -2428,8 +2413,7 @@ for the specified number of times. If not specified, returns the element\n\ endlessly."); static PyTypeObject repeat_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools.repeat", /* tp_name */ sizeof(repeatobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -2561,7 +2545,7 @@ izip_longest_dealloc(iziplongestobject *lz) Py_XDECREF(lz->ittuple); Py_XDECREF(lz->result); Py_XDECREF(lz->fillvalue); - lz->ob_type->tp_free(lz); + Py_Type(lz)->tp_free(lz); } static int @@ -2587,7 +2571,7 @@ izip_longest_next(iziplongestobject *lz) return NULL; if (lz->numactive == 0) return NULL; - if (result->ob_refcnt == 1) { + if (Py_Refcnt(result) == 1) { Py_INCREF(result); for (i=0 ; i < tuplesize ; i++) { it = PyTuple_GET_ITEM(lz->ittuple, i); @@ -2596,7 +2580,7 @@ izip_longest_next(iziplongestobject *lz) item = lz->fillvalue; } else { assert(PyIter_Check(it)); - item = (*it->ob_type->tp_iternext)(it); + item = (*Py_Type(it)->tp_iternext)(it); if (item == NULL) { lz->numactive -= 1; if (lz->numactive == 0) { @@ -2625,7 +2609,7 @@ izip_longest_next(iziplongestobject *lz) item = lz->fillvalue; } else { assert(PyIter_Check(it)); - item = (*it->ob_type->tp_iternext)(it); + item = (*Py_Type(it)->tp_iternext)(it); if (item == NULL) { lz->numactive -= 1; if (lz->numactive == 0) { @@ -2657,8 +2641,7 @@ defaults to None or can be specified by a keyword argument.\n\ "); static PyTypeObject iziplongest_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "itertools.izip_longest", /* tp_name */ sizeof(iziplongestobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -2757,7 +2740,7 @@ inititertools(void) NULL }; - teedataobject_type.ob_type = &PyType_Type; + Py_Type(&teedataobject_type) = &PyType_Type; m = Py_InitModule3("itertools", module_methods, module_doc); if (m == NULL) return; diff --git a/Modules/linuxaudiodev.c b/Modules/linuxaudiodev.c index b435d76..730ec0c 100644 --- a/Modules/linuxaudiodev.c +++ b/Modules/linuxaudiodev.c @@ -441,8 +441,7 @@ lad_getattr(lad_t *xp, char *name) } static PyTypeObject Ladtype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(&PyType_Type, 0) "linuxaudiodev.linux_audio_device", /*tp_name*/ sizeof(lad_t), /*tp_size*/ 0, /*tp_itemsize*/ diff --git a/Modules/md5module.c b/Modules/md5module.c index 5e4f116..f6e4299 100644 --- a/Modules/md5module.c +++ b/Modules/md5module.c @@ -221,8 +221,7 @@ hexdigest() -- return the current digest as a string of hexadecimal digits\n\ copy() -- return a copy of the current md5 object"); static PyTypeObject MD5type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "_md5.md5", /*tp_name*/ sizeof(md5object), /*tp_size*/ 0, /*tp_itemsize*/ @@ -299,7 +298,7 @@ init_md5(void) { PyObject *m, *d; - MD5type.ob_type = &PyType_Type; + Py_Type(&MD5type) = &PyType_Type; if (PyType_Ready(&MD5type) < 0) return; m = Py_InitModule3("_md5", md5_functions, module_doc); diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 091ecd6..a92954b 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -782,8 +782,7 @@ static PyBufferProcs mmap_as_buffer = { }; static PyTypeObject mmap_object_type = { - PyObject_HEAD_INIT(0) /* patched in module init */ - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) /* patched in module init */ "mmap.mmap", /* tp_name */ sizeof(mmap_object), /* tp_size */ 0, /* tp_itemsize */ @@ -1141,7 +1140,7 @@ PyMODINIT_FUNC PyObject *dict, *module; /* Patch the object type */ - mmap_object_type.ob_type = &PyType_Type; + Py_Type(&mmap_object_type) = &PyType_Type; module = Py_InitModule("mmap", mmap_functions); if (module == NULL) diff --git a/Modules/operator.c b/Modules/operator.c index 0a7222a..b6c3d00 100644 --- a/Modules/operator.c +++ b/Modules/operator.c @@ -397,8 +397,7 @@ After, f=itemgetter(2), the call f(r) returns r[2].\n\ After, g=itemgetter(2,5,3), the call g(r) returns (r[2], r[5], r[3])"); static PyTypeObject itemgetter_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "operator.itemgetter", /* tp_name */ sizeof(itemgetterobject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -535,8 +534,7 @@ After, f=attrgetter('name'), the call f(r) returns r.name.\n\ After, g=attrgetter('name', 'date'), the call g(r) returns (r.name, r.date)."); static PyTypeObject attrgetter_type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(NULL, 0) "operator.attrgetter", /* tp_name */ sizeof(attrgetterobject), /* tp_basicsize */ 0, /* tp_itemsize */ diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c index eb59c4d..ebf101a 100644 --- a/Modules/ossaudiodev.c +++ b/Modules/ossaudiodev.c @@ -841,8 +841,7 @@ oss_mixer_getattr(oss_mixer_t *self, char *name) } static PyTypeObject OSSAudioType = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(&PyType_Type, 0) "ossaudiodev.oss_audio_device", /*tp_name*/ sizeof(oss_audio_t), /*tp_size*/ 0, /*tp_itemsize*/ @@ -856,8 +855,7 @@ static PyTypeObject OSSAudioType = { }; static PyTypeObject OSSMixerType = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(&PyType_Type, 0) "ossaudiodev.oss_mixer_device", /*tp_name*/ sizeof(oss_mixer_t), /*tp_size*/ 0, /*tp_itemsize*/ diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c index 23364fe..f502bb5 100644 --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -166,8 +166,7 @@ static PyObject *parser_getattr(PyObject *self, char *name); static PyTypeObject PyST_Type = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "parser.st", /* tp_name */ (int) sizeof(PyST_Object), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -694,7 +693,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num) PyErr_Format(parser_error, "second item in terminal node must be a string," " found %s", - temp->ob_type->tp_name); + Py_Type(temp)->tp_name); Py_DECREF(temp); return 0; } @@ -707,7 +706,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num) PyErr_Format(parser_error, "third item in terminal node must be an" " integer, found %s", - temp->ob_type->tp_name); + Py_Type(temp)->tp_name); Py_DECREF(o); Py_DECREF(temp); return 0; @@ -3233,7 +3232,7 @@ initparser(void) { PyObject *module, *copyreg; - PyST_Type.ob_type = &PyType_Type; + Py_Type(&PyST_Type) = &PyType_Type; module = Py_InitModule("parser", parser_functions); if (module == NULL) return; diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 2b62983..8a78d8c 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -2593,7 +2593,7 @@ extract_time(PyObject *t, long* sec, long* usec) long intval; if (PyFloat_Check(t)) { double tval = PyFloat_AsDouble(t); - PyObject *intobj = t->ob_type->tp_as_number->nb_int(t); + PyObject *intobj = Py_Type(t)->tp_as_number->nb_int(t); if (!intobj) return -1; intval = PyInt_AsLong(intobj); diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index 67f7007..301fbf5 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -974,7 +974,7 @@ readinst(char *buf, int buf_size, PyObject *meth) if (!PyString_Check(str)) { PyErr_Format(PyExc_TypeError, "read() did not return a string object (type=%.400s)", - str->ob_type->tp_name); + Py_Type(str)->tp_name); goto finally; } len = PyString_GET_SIZE(str); @@ -1687,8 +1687,7 @@ xmlparse_clear(xmlparseobject *op) PyDoc_STRVAR(Xmlparsetype__doc__, "XML parser"); static PyTypeObject Xmlparsetype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "pyexpat.xmlparser", /*tp_name*/ sizeof(xmlparseobject) + PyGC_HEAD_SIZE,/*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -1860,7 +1859,7 @@ MODULE_INITFUNC(void) if (modelmod_name == NULL) return; - Xmlparsetype.ob_type = &PyType_Type; + Py_Type(&Xmlparsetype) = &PyType_Type; /* Create the module and add the functions */ m = Py_InitModule3(MODULE_NAME, pyexpat_methods, diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 9eaae84..995f8e7 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -587,8 +587,7 @@ poll_getattr(pollObject *self, char *name) static PyTypeObject poll_Type = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "select.poll", /*tp_name*/ sizeof(pollObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -706,7 +705,7 @@ initselect(void) #else { #endif - poll_Type.ob_type = &PyType_Type; + Py_Type(&poll_Type) = &PyType_Type; PyModule_AddIntConstant(m, "POLLIN", POLLIN); PyModule_AddIntConstant(m, "POLLPRI", POLLPRI); PyModule_AddIntConstant(m, "POLLOUT", POLLOUT); diff --git a/Modules/sha256module.c b/Modules/sha256module.c index 0effb07..24fd47a 100644 --- a/Modules/sha256module.c +++ b/Modules/sha256module.c @@ -409,7 +409,7 @@ SHA256_copy(SHAobject *self, PyObject *unused) { SHAobject *newobj; - if (((PyObject*)self)->ob_type == &SHA256type) { + if (Py_Type(self) == &SHA256type) { if ( (newobj = newSHA256object())==NULL) return NULL; } else { @@ -536,8 +536,7 @@ static PyMemberDef SHA_members[] = { }; static PyTypeObject SHA224type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "_sha256.sha224", /*tp_name*/ sizeof(SHAobject), /*tp_size*/ 0, /*tp_itemsize*/ @@ -571,8 +570,7 @@ static PyTypeObject SHA224type = { }; static PyTypeObject SHA256type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "_sha256.sha256", /*tp_name*/ sizeof(SHAobject), /*tp_size*/ 0, /*tp_itemsize*/ @@ -689,10 +687,10 @@ init_sha256(void) { PyObject *m; - SHA224type.ob_type = &PyType_Type; + Py_Type(&SHA224type) = &PyType_Type; if (PyType_Ready(&SHA224type) < 0) return; - SHA256type.ob_type = &PyType_Type; + Py_Type(&SHA256type) = &PyType_Type; if (PyType_Ready(&SHA256type) < 0) return; m = Py_InitModule("_sha256", SHA_functions); diff --git a/Modules/sha512module.c b/Modules/sha512module.c index 9f47b61..b62cfd9 100644 --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -602,8 +602,7 @@ static PyMemberDef SHA_members[] = { }; static PyTypeObject SHA384type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "_sha512.sha384", /*tp_name*/ sizeof(SHAobject), /*tp_size*/ 0, /*tp_itemsize*/ @@ -637,8 +636,7 @@ static PyTypeObject SHA384type = { }; static PyTypeObject SHA512type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "_sha512.sha512", /*tp_name*/ sizeof(SHAobject), /*tp_size*/ 0, /*tp_itemsize*/ @@ -755,10 +753,10 @@ init_sha512(void) { PyObject *m; - SHA384type.ob_type = &PyType_Type; + Py_Type(&SHA384type) = &PyType_Type; if (PyType_Ready(&SHA384type) < 0) return; - SHA512type.ob_type = &PyType_Type; + Py_Type(&SHA512type) = &PyType_Type; if (PyType_Ready(&SHA512type) < 0) return; m = Py_InitModule("_sha512", SHA_functions); diff --git a/Modules/shamodule.c b/Modules/shamodule.c index 8d68d16..e268352 100644 --- a/Modules/shamodule.c +++ b/Modules/shamodule.c @@ -489,8 +489,7 @@ static PyGetSetDef SHA_getseters[] = { }; static PyTypeObject SHAtype = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "_sha.sha", /*tp_name*/ sizeof(SHAobject), /*tp_size*/ 0, /*tp_itemsize*/ @@ -577,7 +576,7 @@ init_sha(void) { PyObject *m; - SHAtype.ob_type = &PyType_Type; + Py_Type(&SHAtype) = &PyType_Type; if (PyType_Ready(&SHAtype) < 0) return; m = Py_InitModule("_sha", SHA_functions); diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 97ca816..d319ca3 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1245,7 +1245,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, PyExc_TypeError, "getsockaddrarg: " "AF_NETLINK address must be tuple, not %.500s", - args->ob_type->tp_name); + Py_Type(args)->tp_name); return 0; } if (!PyArg_ParseTuple(args, "II:getsockaddrarg", &pid, &groups)) @@ -1268,7 +1268,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, PyExc_TypeError, "getsockaddrarg: " "AF_INET address must be tuple, not %.500s", - args->ob_type->tp_name); + Py_Type(args)->tp_name); return 0; } if (!PyArg_ParseTuple(args, "eti:getsockaddrarg", @@ -1298,7 +1298,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, PyExc_TypeError, "getsockaddrarg: " "AF_INET6 address must be tuple, not %.500s", - args->ob_type->tp_name); + Py_Type(args)->tp_name); return 0; } if (!PyArg_ParseTuple(args, "eti|ii", @@ -1420,7 +1420,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, PyExc_TypeError, "getsockaddrarg: " "AF_PACKET address must be tuple, not %.500s", - args->ob_type->tp_name); + Py_Type(args)->tp_name); return 0; } if (!PyArg_ParseTuple(args, "si|iis#", &interfaceName, @@ -2843,7 +2843,7 @@ sock_dealloc(PySocketSockObject *s) { if (s->sock_fd != -1) (void) SOCKETCLOSE(s->sock_fd); - s->ob_type->tp_free((PyObject *)s); + Py_Type(s)->tp_free((PyObject *)s); } @@ -2928,8 +2928,7 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds) /* Type object for socket objects. */ static PyTypeObject sock_type = { - PyObject_HEAD_INIT(0) /* Must fill in type value later */ - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) /* Must fill in type value later */ "_socket.socket", /* tp_name */ sizeof(PySocketSockObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -3555,7 +3554,7 @@ socket_ntohl(PyObject *self, PyObject *arg) else return PyErr_Format(PyExc_TypeError, "expected int/long, %s found", - arg->ob_type->tp_name); + Py_Type(arg)->tp_name); if (x == (unsigned long) -1 && PyErr_Occurred()) return NULL; return PyLong_FromUnsignedLong(ntohl(x)); @@ -3624,7 +3623,7 @@ socket_htonl(PyObject *self, PyObject *arg) else return PyErr_Format(PyExc_TypeError, "expected int/long, %s found", - arg->ob_type->tp_name); + Py_Type(arg)->tp_name); return PyLong_FromUnsignedLong(htonl((unsigned long)x)); } @@ -4274,7 +4273,7 @@ init_socket(void) if (!os_init()) return; - sock_type.ob_type = &PyType_Type; + Py_Type(&sock_type) = &PyType_Type; m = Py_InitModule3(PySocket_MODULE_NAME, socket_methods, socket_doc); diff --git a/Modules/sunaudiodev.c b/Modules/sunaudiodev.c index 802184d..4288403 100644 --- a/Modules/sunaudiodev.c +++ b/Modules/sunaudiodev.c @@ -42,8 +42,8 @@ static sadstatusobject *sads_alloc(void); /* Forward */ static PyObject *SunAudioError; -#define is_sadobject(v) ((v)->ob_type == &Sadtype) -#define is_sadstatusobject(v) ((v)->ob_type == &Sadstatustype) +#define is_sadobject(v) (Py_Type(v) == &Sadtype) +#define is_sadstatusobject(v) (Py_Type(v) == &Sadstatustype) static sadobject * @@ -409,8 +409,7 @@ sads_setattr(sadstatusobject *xp, char *name, PyObject *v) static PyTypeObject Sadtype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(&PyType_Type, 0) "sunaudiodev.sun_audio_device", /*tp_name*/ sizeof(sadobject), /*tp_size*/ 0, /*tp_itemsize*/ @@ -424,8 +423,7 @@ static PyTypeObject Sadtype = { }; static PyTypeObject Sadstatustype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(&PyType_Type, 0) "sunaudiodev.sun_audio_device_status", /*tp_name*/ sizeof(sadstatusobject), /*tp_size*/ 0, /*tp_itemsize*/ diff --git a/Modules/threadmodule.c b/Modules/threadmodule.c index 036619a..9e40771 100644 --- a/Modules/threadmodule.c +++ b/Modules/threadmodule.c @@ -126,8 +126,7 @@ lock_getattr(lockobject *self, char *name) } static PyTypeObject Locktype = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(&PyType_Type, 0) "thread.lock", /*tp_name*/ sizeof(lockobject), /*tp_size*/ 0, /*tp_itemsize*/ @@ -251,7 +250,7 @@ local_dealloc(localobject *self) } local_clear(self); - self->ob_type->tp_free((PyObject*)self); + Py_Type(self)->tp_free((PyObject*)self); } static PyObject * @@ -283,8 +282,8 @@ _ldict(localobject *self) Py_INCREF(ldict); self->dict = ldict; /* still borrowed */ - if (self->ob_type->tp_init != PyBaseObject_Type.tp_init && - self->ob_type->tp_init((PyObject*)self, + if (Py_Type(self)->tp_init != PyBaseObject_Type.tp_init && + Py_Type(self)->tp_init((PyObject*)self, self->args, self->kw) < 0) { /* we need to get rid of ldict from thread so we create a new one the next time we do an attr @@ -336,8 +335,7 @@ static PyGetSetDef local_getset[] = { static PyObject *local_getattro(localobject *, PyObject *); static PyTypeObject localtype = { - PyObject_HEAD_INIT(NULL) - /* ob_size */ 0, + PyVarObject_HEAD_INIT(NULL, 0) /* tp_name */ "thread._local", /* tp_basicsize */ sizeof(localobject), /* tp_itemsize */ 0, @@ -388,7 +386,7 @@ local_getattro(localobject *self, PyObject *name) if (ldict == NULL) return NULL; - if (self->ob_type != &localtype) + if (Py_Type(self) != &localtype) /* use generic lookup for subtypes */ return PyObject_GenericGetAttr((PyObject *)self, name); diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index a30d30c..fac9adc 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -1134,8 +1134,7 @@ static PyMethodDef unicodedata_functions[] = { static PyTypeObject UCD_Type = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "unicodedata.UCD", /*tp_name*/ sizeof(PreviousDBVersion), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -1193,7 +1192,7 @@ initunicodedata(void) { PyObject *m, *v; - UCD_Type.ob_type = &PyType_Type; + Py_Type(&UCD_Type) = &PyType_Type; m = Py_InitModule3( "unicodedata", unicodedata_functions, unicodedata_docstring); diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c index ea66eef..0923f81 100644 --- a/Modules/xxmodule.c +++ b/Modules/xxmodule.c @@ -25,7 +25,7 @@ typedef struct { static PyTypeObject Xxo_Type; -#define XxoObject_Check(v) ((v)->ob_type == &Xxo_Type) +#define XxoObject_Check(v) (Py_Type(v) == &Xxo_Type) static XxoObject * newXxoObject(PyObject *arg) @@ -97,8 +97,7 @@ Xxo_setattr(XxoObject *self, char *name, PyObject *v) static PyTypeObject Xxo_Type = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "xxmodule.Xxo", /*tp_name*/ sizeof(XxoObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -216,8 +215,7 @@ xx_roj(PyObject *self, PyObject *args) static PyTypeObject Str_Type = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "xxmodule.Str", /*tp_name*/ 0, /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -272,8 +270,7 @@ null_richcompare(PyObject *self, PyObject *other, int op) static PyTypeObject Null_Type = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "xxmodule.Null", /*tp_name*/ 0, /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/Modules/xxsubtype.c b/Modules/xxsubtype.c index 88ce6c5..0cf0b81 100644 --- a/Modules/xxsubtype.c +++ b/Modules/xxsubtype.c @@ -101,8 +101,7 @@ static PyGetSetDef spamlist_getsets[] = { }; static PyTypeObject spamlist_type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "xxsubtype.spamlist", sizeof(spamlistobject), 0, @@ -193,8 +192,7 @@ static PyMemberDef spamdict_members[] = { }; static PyTypeObject spamdict_type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "xxsubtype.spamdict", sizeof(spamdictobject), 0, diff --git a/Modules/zipimport.c b/Modules/zipimport.c index 69b2881..ae6af46 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -181,7 +181,7 @@ zipimporter_dealloc(ZipImporter *self) Py_XDECREF(self->archive); Py_XDECREF(self->prefix); Py_XDECREF(self->files); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } static PyObject * @@ -561,8 +561,7 @@ a valid Zip archive."); #define DEFERRED_ADDRESS(ADDR) 0 static PyTypeObject ZipImporter_Type = { - PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) - 0, + PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "zipimport.zipimporter", sizeof(ZipImporter), 0, /* tp_itemsize */ diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index da31e8b..43f435a 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -935,8 +935,7 @@ static PyMethodDef zlib_methods[] = }; static PyTypeObject Comptype = { - PyObject_HEAD_INIT(0) - 0, + PyVarObject_HEAD_INIT(0, 0) "zlib.Compress", sizeof(compobject), 0, @@ -952,8 +951,7 @@ static PyTypeObject Comptype = { }; static PyTypeObject Decomptype = { - PyObject_HEAD_INIT(0) - 0, + PyVarObject_HEAD_INIT(0, 0) "zlib.Decompress", sizeof(compobject), 0, @@ -987,8 +985,8 @@ PyMODINIT_FUNC PyInit_zlib(void) { PyObject *m, *ver; - Comptype.ob_type = &PyType_Type; - Decomptype.ob_type = &PyType_Type; + Py_Type(&Comptype) = &PyType_Type; + Py_Type(&Decomptype) = &PyType_Type; m = Py_InitModule4("zlib", zlib_methods, zlib_module_documentation, (PyObject*)NULL,PYTHON_API_VERSION); |